MPD icon indicating copy to clipboard operation
MPD copied to clipboard

Sort and limit results from sticker database

Open gilphilbert opened this issue 3 years ago • 4 comments

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

gilphilbert avatar Feb 23 '21 20:02 gilphilbert

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

jcorporation avatar Feb 24 '21 20:02 jcorporation

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}

gilphilbert avatar Feb 24 '21 23:02 gilphilbert

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?

jcorporation avatar Oct 20 '23 13:10 jcorporation

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

MaxKellermann avatar Oct 20 '23 13:10 MaxKellermann

As mentioned in #1895

jcorporation avatar Apr 05 '24 15:04 jcorporation