Add new sort tokens for pools; update API doc

This commit is contained in:
Ruin0x11 2021-05-08 16:15:39 -07:00
parent 47377395a2
commit 161a3939c9
2 changed files with 50 additions and 45 deletions

View file

@ -793,38 +793,39 @@ data.
**Sort style tokens** **Sort style tokens**
| `<value>` | Description | | `<value>` | Description |
| ---------------- | ------------------------------------------------ | | ---------------- | ------------------------------------------------ |
| `random` | as random as it can get | | `random` | as random as it can get |
| `id` | highest to lowest post number | | `id` | highest to lowest post number |
| `score` | highest scored | | `score` | highest scored |
| `tag-count` | with most tags | | `tag-count` | with most tags |
| `comment-count` | most commented first | | `comment-count` | most commented first |
| `fav-count` | loved by most | | `fav-count` | loved by most |
| `note-count` | with most annotations | | `note-count` | with most annotations |
| `relation-count` | with most relations | | `relation-count` | with most relations |
| `feature-count` | most often featured | | `feature-count` | most often featured |
| `file-size` | largest files first | | `file-size` | largest files first |
| `image-width` | widest images first | | `image-width` | widest images first |
| `image-height` | tallest images first | | `image-height` | tallest images first |
| `image-area` | largest images first | | `image-area` | largest images first |
| `width` | alias of `image-width` | | `width` | alias of `image-width` |
| `height` | alias of `image-height` | | `height` | alias of `image-height` |
| `area` | alias of `image-area` | | `area` | alias of `image-area` |
| `creation-date` | newest to oldest (pretty much same as id) | | `creation-date` | newest to oldest (pretty much same as id) |
| `creation-time` | alias of `creation-date` | | `creation-time` | alias of `creation-date` |
| `date` | alias of `creation-date` | | `date` | alias of `creation-date` |
| `time` | alias of `creation-date` | | `time` | alias of `creation-date` |
| `last-edit-date` | like creation-date, only looks at last edit time | | `last-edit-date` | like creation-date, only looks at last edit time |
| `last-edit-time` | alias of `last-edit-date` | | `last-edit-time` | alias of `last-edit-date` |
| `edit-date` | alias of `last-edit-date` | | `edit-date` | alias of `last-edit-date` |
| `edit-time` | alias of `last-edit-date` | | `edit-time` | alias of `last-edit-date` |
| `comment-date` | recently commented by anyone | | `comment-date` | recently commented by anyone |
| `comment-time` | alias of `comment-date` | | `comment-time` | alias of `comment-date` |
| `fav-date` | recently added to favorites by anyone | | `fav-date` | recently added to favorites by anyone |
| `fav-time` | alias of `fav-date` | | `fav-time` | alias of `fav-date` |
| `feature-date` | recently featured | | `feature-date` | recently featured |
| `feature-time` | alias of `feature-time` | | `feature-time` | alias of `feature-time` |
| `pool` | post order of the pool referenced by the `pool:` named token in the same search query |
**Special tokens** **Special tokens**
@ -1333,6 +1334,7 @@ data.
| `<key>` | Description | | `<key>` | Description |
| ------------------- | ----------------------------------------- | | ------------------- | ----------------------------------------- |
| `id` | having given pool number |
| `name` | having given name (accepts wildcards) | | `name` | having given name (accepts wildcards) |
| `category` | having given category (accepts wildcards) | | `category` | having given category (accepts wildcards) |
| `creation-date` | created at given date | | `creation-date` | created at given date |
@ -1345,18 +1347,19 @@ data.
**Sort style tokens** **Sort style tokens**
| `<value>` | Description | | `<value>` | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| `random` | as random as it can get | | `random` | as random as it can get |
| `name` | A to Z | | `id` | highest to lowest pool number |
| `category` | category (A to Z) | | `name` | A to Z |
| `creation-date` | recently created first | | `category` | category (A to Z) |
| `creation-time` | alias of `creation-date` | | `creation-date` | recently created first |
| `last-edit-date` | recently edited first | | `creation-time` | alias of `creation-date` |
| `last-edit-time` | alias of `creation-time` | | `last-edit-date` | recently edited first |
| `edit-date` | alias of `creation-time` | | `last-edit-time` | alias of `creation-time` |
| `edit-time` | alias of `creation-time` | | `edit-date` | alias of `creation-time` |
| `post-count` | used in most posts first | | `edit-time` | alias of `creation-time` |
| `post-count` | used in most posts first |
**Special tokens** **Special tokens**

View file

@ -30,7 +30,7 @@ class PoolSearchConfig(BaseSearchConfig):
raise NotImplementedError() raise NotImplementedError()
def finalize_query(self, query: SaQuery) -> SaQuery: def finalize_query(self, query: SaQuery) -> SaQuery:
return query.order_by(model.Pool.first_name.asc()) return query.order_by(model.Pool.pool_id.desc())
@property @property
def anonymous_filter(self) -> Filter: def anonymous_filter(self) -> Filter:
@ -45,6 +45,7 @@ class PoolSearchConfig(BaseSearchConfig):
def named_filters(self) -> Dict[str, Filter]: def named_filters(self) -> Dict[str, Filter]:
return util.unalias_dict( return util.unalias_dict(
[ [
(["id"], search_util.create_num_filter(model.Pool.pool_id)),
( (
["name"], ["name"],
search_util.create_subquery_filter( search_util.create_subquery_filter(
@ -91,6 +92,7 @@ class PoolSearchConfig(BaseSearchConfig):
["random"], ["random"],
(sa.sql.expression.func.random(), self.SORT_NONE), (sa.sql.expression.func.random(), self.SORT_NONE),
), ),
(["id"], (model.Pool.pool_id, self.SORT_DESC)),
(["name"], (model.Pool.first_name, self.SORT_ASC)), (["name"], (model.Pool.first_name, self.SORT_ASC)),
(["category"], (model.PoolCategory.name, self.SORT_ASC)), (["category"], (model.PoolCategory.name, self.SORT_ASC)),
( (