-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add endpoint to retrieve project types #139
base: main
Are you sure you want to change the base?
Conversation
…prove response structure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @andersy005 !
The payload generally looks good! If it'd be helpful to test the frontend integration before deploying to production, I think we might need to make the /projects
changes at the same time to be able to test the way these pieces fit together.
offsets_db_api/routers/projects.py
Outdated
result = session.exec(statement).all() | ||
top = [project_type for project_type, _ in result[:top_n]] | ||
others = [project_type for project_type, _ in result[top_n:]] | ||
return ProjectTypes(top=top, others=others) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we going to support the general /projects?project_type=Other
query on the /projects
endpoint? I think that would be helpful because including all of the "others" entries would make for a huge request URL.
If that's the case, should we use consistent naming here?
return ProjectTypes(top=top, others=others) | |
return ProjectTypes(Top=top, Other=others) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one idea that comes to mind is doing something along these lines:
update the /projects
endpoint by adding the top_project_types
parameter as a query parameter, and handle the project_type=Other
logic when it's used in combination with top_project_types
.
GET /projects?project_type=Other&top_project_types=Type1,Type2,Type3
this would translate in using the NOT IN
clause on on the backend to exclude the top project types if project_type=Other
is detected.
SELECT ...
....
WHERE project_type NOT in top_project_types
one advantage of this approach is that we avoid having to query the database to get the list of Other
types and instead take advantage of the fact that we already know which types are in Top
@katamartin, how does this sound?
Co-authored-by: Kata Martin <[email protected]>
@katamartin, this is ready