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

Sort all image queries by publishedon date #140

Merged

Conversation

jeremy-moffitt
Copy link
Collaborator

To ensure that images trimmed from oversized queries are the oldest ones, it is necessary to sort the image/state query by publishedon date. For consistency, sort the other image queries the same way.

@jeremy-moffitt jeremy-moffitt force-pushed the sort_images_publishedon branch 2 times, most recently from 502ba60 to 22588c3 Compare July 19, 2024 16:38
Copy link
Contributor

@rtamalin rtamalin left a comment

Choose a reason for hiding this comment

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

LGTM

pint_server/app.py Outdated Show resolved Hide resolved
@jeremy-moffitt jeremy-moffitt force-pushed the sort_images_publishedon branch 3 times, most recently from dd7b4cb to 765529f Compare July 19, 2024 19:27
Copy link
Collaborator

Choose a reason for hiding this comment

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

Got this error on line 573 while doing API sanity tests. TypeError: count() takes exactly one argument (0 given).
I think we need to change it to if len(images) == 0: since images is a list object.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

made the recommended change, though this has me a little nervous, not because of the len check... but because I didn't anticipate this would change the type of the images collection...

Copy link
Contributor

Choose a reason for hiding this comment

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

This probably goes back to aggressively adding the .all() in all those previous cases.

Without the .all() the object returned is a list generator that and be used to render an actual list if needed, but it is also an SQLAlchemy query object that can have further query operations applied to it, including the count() method which would return a count of the number of entries in the query response. Once we actualised the query results into a Python list the count method is no longer allowed, and you need to use len() to obtain the length of the list.

Copy link
Collaborator

@guangyee guangyee left a comment

Choose a reason for hiding this comment

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

I ran some manual sanity tests and the changes looks good.

@guangyee guangyee merged commit eaff506 into SUSE-Enceladus:master Jul 22, 2024
3 checks passed
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.

None yet

3 participants