feat(web): dropdown sort and time filters with year support
This commit is contained in:
1 parent
bc3bef0743
commit
9be7d1cab2
10 files changed
+191
-67
No files matched your search
@@ -53,6 +53,7 @@ def test_overview():
|
||||
assert overview["fans"]["follower"] == 1020
|
||||
assert overview["fans"]["delta_1d"] == 10
|
||||
assert overview["preview"] is False
|
||||
assert overview["years"] == [2026]
|
||||
assert "snapshot" in overview["tasks"]
|
||||
finally:
|
||||
db.close()
|
||||
@@ -419,6 +420,32 @@ def test_duration_efficiency_queries():
|
||||
db.close()
|
||||
|
||||
|
||||
def test_year_filter_and_published_sort():
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
db, q = setup(tmp)
|
||||
try:
|
||||
by_year = q.list_videos(sort="view", year=2026)
|
||||
assert [item["aid"] for item in by_year["items"]] == [102, 101, 103]
|
||||
assert by_year["year"] == 2026
|
||||
|
||||
none = q.list_videos(sort="view", year=2025)
|
||||
assert none["items"] == []
|
||||
assert none["total"] == 0
|
||||
|
||||
published = q.list_videos(sort="published")
|
||||
assert [item["aid"] for item in published["items"]] == [103, 101, 102]
|
||||
|
||||
added = q.list_videos(sort="added")
|
||||
assert added["total"] == 3
|
||||
|
||||
ups = q.list_ups(sort="efficiency", year=2026)
|
||||
assert ups["year"] == 2026 and ups["total"] == 2
|
||||
ups_none = q.list_ups(sort="views", year=2025)
|
||||
assert ups_none["total"] == 0
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
def test_about_payload():
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
db, q = setup(tmp)
|
||||
@@ -454,6 +481,7 @@ def main_test():
|
||||
test_up_queries()
|
||||
test_query_cache_invalidation()
|
||||
test_duration_efficiency_queries()
|
||||
test_year_filter_and_published_sort()
|
||||
test_about_payload()
|
||||
test_fans_custom_range_modes()
|
||||
test_fans_candidates_system_and_export()
|
||||
|
||||
@@ -111,6 +111,15 @@ def test_readonly_routes_and_static():
|
||||
items = json.loads(payload)["data"]["items"]
|
||||
assert items and items[0]["aid"] == 102
|
||||
|
||||
status, _, payload = running.json("/api/videos?year=2026")
|
||||
assert status == 200
|
||||
assert payload["data"]["year"] == 2026
|
||||
status, _, payload = running.json("/api/videos?year=1800")
|
||||
assert status == 400
|
||||
status, _, payload = running.json("/api/ups?year=2026")
|
||||
assert status == 200
|
||||
assert payload["data"]["year"] == 2026
|
||||
|
||||
status, _, payload = running.request("/api/ups")
|
||||
assert status == 200
|
||||
assert json.loads(payload)["data"]["sort"] == "efficiency"
|
||||
|
||||
Reference in new issue
Block a user