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

@ -825,6 +825,7 @@ data.
| `fav-time` | alias of `fav-date` |
| `feature-date` | recently featured |
| `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**
@ -1333,6 +1334,7 @@ data.
| `<key>` | Description |
| ------------------- | ----------------------------------------- |
| `id` | having given pool number |
| `name` | having given name (accepts wildcards) |
| `category` | having given category (accepts wildcards) |
| `creation-date` | created at given date |
@ -1348,6 +1350,7 @@ data.
| `<value>` | Description |
| ------------------- | ---------------------------- |
| `random` | as random as it can get |
| `id` | highest to lowest pool number |
| `name` | A to Z |
| `category` | category (A to Z) |
| `creation-date` | recently created first |

View file

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