-
Notifications
You must be signed in to change notification settings - Fork 8
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
Sort all image queries by publishedon date #140
Conversation
502ba60
to
22588c3
Compare
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.
LGTM
dd7b4cb
to
765529f
Compare
765529f
to
0f03ac1
Compare
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.
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.
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.
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...
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.
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.
0f03ac1
to
afd1f89
Compare
afd1f89
to
69f22e3
Compare
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.
I ran some manual sanity tests and the changes looks good.
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.