Skip to content
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

Type param #177

Merged
merged 4 commits into from
Feb 5, 2024
Merged

Type param #177

merged 4 commits into from
Feb 5, 2024

Conversation

femalves
Copy link
Contributor

@femalves femalves commented Feb 2, 2024

Desired behavior

Request

https://devapi.adsabs.harvard.edu/v1/biblib/libraries?start=0&rows=10&sort=date_last_modified&order=desc&type=collaborator 

Response

{
  count; // total count of all libraries shared with me in this case
  libraries: [ .... ]; // only the first 10 libraries shared with me in this case, sorted 
}

biblib/views/user_view.py Outdated Show resolved Hide resolved
biblib/views/user_view.py Show resolved Hide resolved
@shinyichen shinyichen self-requested a review February 2, 2024 19:40
Copy link
Member

@shinyichen shinyichen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just the comment about efficiency.

Copy link
Contributor

@tjacovich tjacovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments but overall I think it looks good based on my understanding of what we are trying to achieve.

@@ -228,8 +222,9 @@ def get(self):
if sort_order not in ['asc', 'desc']:
raise ValueError

ownership = get_params.get('ownership', default=False, type=check_boolean)
current_app.logger.debug("GET params: {}, start: {}, end: {}".format(get_params, start, rows))
type = get_params.get('type', default='all', type=str)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only concern on this is that type is a python builtin, so it might be worth renaming to something safer in case type() becomes relevant in the future.

libraries_response['shared_with_me'] = shared_with_me
else:
libraries_response['libraries'] = my_libraries
if type == 'all' or (type == 'owner' and main_permission in ['owner']) or (type == 'collaborator' and main_permission in ['admin', 'read', 'write']):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I am missing something, but do we still need this if with the filtering incorporated in the new method you wrote above?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, seems like this part and the slicing of list (below) are not needed anymore

@@ -58,9 +58,24 @@ def retrieve_user_email(owner_absolute_uid):
service
)
return response

@classmethod
def get_user_libraries(cls, session, service_uid, sort_col, sort_order, type):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this method looks good and also makes that previous query a lot more readable.


if type == 'owner':
query = query.filter(Permissions.permissions['owner'].astext.cast(Boolean).is_(True))
elif type != 'all':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a particular reason you opted for !='all' instead of =='collaborator'?

Copy link
Contributor

@tjacovich tjacovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Things look good to me

@femalves femalves merged commit d1c886d into master Feb 5, 2024
1 check passed
@femalves femalves deleted the type_param branch April 18, 2024 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants