[NO MERGE] fake PR for comments - #2
Conversation
| psycopg2 | ||
| pydantic>=2.7.0,<3.0.0 | ||
| redis | ||
| sqlmodel No newline at end of file |
There was a problem hiding this comment.
Do we actually use sqlmodel?
There was a problem hiding this comment.
We use sqlalchemy which is a part of sqlmodel. We could reduce this dependency to sqlalchemy instead, good catch.
|
|
||
| COPY ./api /app/api | ||
|
|
||
| CMD ["fastapi", "run", "api/main.py", "--port", "80", "--workers", "4"] |
There was a problem hiding this comment.
@sblack-usu why 4 workers? Might we need this to be more flexible for deployment into our cluster, depending on available resources?
| def user_has_edit_access(user_id: int, resource_id: str): | ||
| query = """SELECT DISTINCT hs_core_genericresource.short_id | ||
| FROM hs_core_genericresource | ||
| LEFT OUTER JOIN hs_access_control_userresourceprivilege | ||
| ON (hs_core_genericresource.page_ptr_id = hs_access_control_userresourceprivilege.resource_id) | ||
| LEFT OUTER JOIN hs_access_control_resourceaccess | ||
| ON (hs_core_genericresource.page_ptr_id = hs_access_control_resourceaccess.resource_id) | ||
| LEFT OUTER JOIN hs_access_control_groupresourceprivilege | ||
| ON (hs_core_genericresource.page_ptr_id = hs_access_control_groupresourceprivilege.resource_id) | ||
| LEFT OUTER JOIN auth_group | ||
| ON (hs_access_control_groupresourceprivilege.group_id = auth_group.id) | ||
| LEFT OUTER JOIN hs_access_control_usergroupprivilege | ||
| ON (auth_group.id = hs_access_control_usergroupprivilege.group_id) | ||
| LEFT OUTER JOIN hs_access_control_groupaccess | ||
| ON (auth_group.id = hs_access_control_groupaccess.group_id) | ||
| INNER JOIN pages_page | ||
| ON (hs_core_genericresource.page_ptr_id = pages_page.id) | ||
| WHERE ((hs_access_control_userresourceprivilege.privilege = 1 | ||
| AND hs_access_control_userresourceprivilege.user_id = :user_id) | ||
| OR (hs_access_control_userresourceprivilege.privilege <= 2 | ||
| AND hs_access_control_userresourceprivilege.user_id = :user_id | ||
| AND NOT hs_access_control_resourceaccess.immutable) | ||
| OR (hs_access_control_usergroupprivilege.user_id = :user_id | ||
| AND hs_access_control_groupaccess.active | ||
| AND hs_access_control_groupresourceprivilege.privilege = 2 | ||
| AND NOT hs_access_control_resourceaccess.immutable)) | ||
| AND hs_core_genericresource.short_id = :resource_id""" |
There was a problem hiding this comment.
I know our User and Resource models are pretty much set in stone, and we don't really anticipate drift between these queries and our models in HydroShare...so I'm going to ignore my distaste for these raw queries. 😄
I'm sure that we chose raw SQL queries like this for performance reasons, right?
|
@sblack-usu other than removing the unnecessary dependency and addressing the Q about workers, this looks pretty great! |
No description provided.