Coverage for polar/event/sorting.py: 100%
21 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 12:42 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 12:42 +0000
1from enum import StrEnum
2from typing import Annotated
4from fastapi import Depends
6from polar.kit.sorting import Sorting, SortingGetter
9class EventSortProperty(StrEnum):
10 timestamp = "timestamp"
13ListSorting = Annotated[
14 list[Sorting[EventSortProperty]],
15 Depends(SortingGetter(EventSortProperty, ["-timestamp"])),
16]
19class EventNamesSortProperty(StrEnum):
20 event_name = "name" # `name` is a reserved word, so we use `event_name`
21 occurrences = "occurrences"
22 first_seen = "first_seen"
23 last_seen = "last_seen"
26EventNamesSorting = Annotated[
27 list[Sorting[EventNamesSortProperty]],
28 Depends(
29 SortingGetter(
30 EventNamesSortProperty,
31 ["-last_seen"],
32 )
33 ),
34]
37class EventStatisticsSortProperty(StrEnum):
38 event_name = "name" # `name` is a reserved word, so we use `event_name`
39 occurrences = "occurrences"
40 total = "total"
41 average = "average"
42 p95 = "p95"
43 p99 = "p99"
46EventStatisticsSorting = Annotated[
47 list[Sorting[EventStatisticsSortProperty]],
48 Depends(
49 SortingGetter(
50 EventStatisticsSortProperty,
51 ["-total"],
52 )
53 ),
54]