mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-07 06:12:20 -04:00
Add helper to parse an enum from query args & use it. (#14956)
The `parse_enum` helper pulls an enum value from the query string (by delegating down to the parse_string helper with values generated from the enum). This is used to pull out "f" and "b" in most places and then we thread the resulting Direction enum throughout more code.
This commit is contained in:
parent
230a831c73
commit
1182ae5063
25 changed files with 176 additions and 96 deletions
|
@ -22,7 +22,7 @@ from typing_extensions import Counter
|
|||
|
||||
from twisted.internet.defer import DeferredLock
|
||||
|
||||
from synapse.api.constants import EventContentFields, EventTypes, Membership
|
||||
from synapse.api.constants import Direction, EventContentFields, EventTypes, Membership
|
||||
from synapse.api.errors import StoreError
|
||||
from synapse.storage.database import (
|
||||
DatabasePool,
|
||||
|
@ -663,7 +663,7 @@ class StatsStore(StateDeltasStore):
|
|||
from_ts: Optional[int] = None,
|
||||
until_ts: Optional[int] = None,
|
||||
order_by: Optional[str] = UserSortOrder.USER_ID.value,
|
||||
direction: Optional[str] = "f",
|
||||
direction: Direction = Direction.FORWARDS,
|
||||
search_term: Optional[str] = None,
|
||||
) -> Tuple[List[JsonDict], int]:
|
||||
"""Function to retrieve a paginated list of users and their uploaded local media
|
||||
|
@ -714,7 +714,7 @@ class StatsStore(StateDeltasStore):
|
|||
500, "Incorrect value for order_by provided: %s" % order_by
|
||||
)
|
||||
|
||||
if direction == "b":
|
||||
if direction == Direction.BACKWARDS:
|
||||
order = "DESC"
|
||||
else:
|
||||
order = "ASC"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue