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 and limit results from sticker database #1103

Closed
gilphilbert opened this issue Feb 23, 2021 · 5 comments
Closed

Sort and limit results from sticker database #1103

gilphilbert opened this issue Feb 23, 2021 · 5 comments
Labels

Comments

@gilphilbert
Copy link

Feature request

I'd like to be able to retrieve a set of stickers ordered in a descending list, preferably with a limit in place:

sticker find {TYPE} {URI} {NAME} sort {SORT_DIRECTION}
and
sticker find {TYPE} {URI} {NAME} sort {SORT_DIRECTION} limit {LIMIT}

For example:
sticker find song "" playCount sort desc limit 100

This would allow retrieval of stickers that are numeric or alphabetic and be able to pull the "top 100 played songs". It would also be possible to set a sticker for "date added" and retrieve a list of "50 most recent additions". This allows for dynamic playlists without needing to add extra databases.

I know we can use:
sticker find {TYPE} {URI} {NAME}

Then sort, but for large collections (10,000+ songs) this means manually sorting thousands of objects and discarding almost all of them when the SQLite database can do that for us quickly and easily

@jcorporation
Copy link
Member

I would vote for a window parameter instead of a limit parameter.

@gilphilbert
Copy link
Author

gilphilbert commented Feb 24, 2021

Good idea, if we introduce an optional start and limit in addition to sort then this allows the most amount of flexibility:
sticker find {TYPE} {URI} {NAME} sort {SORT_DIRECTION} start {START} limit {LIMIT}

To get everything:
sticker find {TYPE} {URI} {NAME} sort {SORT_DIRECTION}
For a simple "limit":
sticker find {TYPE} {URI} {NAME} sort {SORT_DIRECTION} limit {LIMIT}
For "pagination":
sticker find {TYPE} {URI} {NAME} sort {SORT_DIRECTION} start {START} limit {LIMIT}

@jcorporation
Copy link
Member

I will try to implement this.

To maintain a consistent syntax I would propose the following:

sticker find {TYPE} {URI} {NAME} [sort {uri|value}] [window {START:END}]

sticker find {TYPE} {URI} {NAME} = {VALUE} [sort {uri|value}] [window {START:END}]

@MaxKellermann: Does the syntax fit for you?

@MaxKellermann
Copy link
Member

Yes, that's like the existing database find syntax.

@jcorporation
Copy link
Member

As mentioned in #1895

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants