-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat(server): sort assets randomly from the API 'api/search/metadata' endpoint by including 'order': 'rand' in the API call. #12741
Conversation
bc6a4cd
to
0246c41
Compare
0246c41
to
8d9f49f
Compare
builder.orderBy('asset.fileCreatedAt', options.orderDirection ?? 'DESC'); | ||
|
||
if (options.random) { | ||
mode = PaginationMode.LIMIT_OFFSET; |
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 don't think limit/offset is safe here because there are possible joins with one-to-many or many-to-many relations.
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.
A thought: you could make a separate /search/random
endpoint that takes the same options as the smart search endpoint but without the query field.
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 see. The other pagination throws an error I did not know how to fix. If you have time can you take a look?
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.
Nevermind, I think I figured it out.
fec9f98
to
af077b1
Compare
af077b1
to
b0b2012
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
Warning
GET /api/assets/random
is now deprecated in favor ofPOST /api/search/random
Goal is to simplify getting random photos for a kiosk. The new API call works as such: