feat(web): default video sort to published and UP sort to avg_views
This commit is contained in:
1 parent
764bde65d9
commit
11930db2bf
8 files changed
+31
-20
No files matched your search
@@ -861,7 +861,7 @@ class DashboardQueries:
|
||||
def list_videos(
|
||||
self,
|
||||
*,
|
||||
sort: str = "heat",
|
||||
sort: str = "published",
|
||||
within_days: int | None = None,
|
||||
year: int | None = None,
|
||||
growth_days: int | str = "auto",
|
||||
@@ -896,7 +896,7 @@ class DashboardQueries:
|
||||
def _list_videos_uncached(
|
||||
self,
|
||||
*,
|
||||
sort: str = "heat",
|
||||
sort: str = "published",
|
||||
within_days: int | None = None,
|
||||
year: int | None = None,
|
||||
growth_days: int | str = "auto",
|
||||
|
||||
@@ -370,7 +370,7 @@ border-color:#3a2c22;color:#f3e9dc}button{background:#e9b97c;color:#2a1a10}}
|
||||
return
|
||||
if path == "/api/videos":
|
||||
self._send_json(HTTPStatus.OK, queries.list_videos(
|
||||
sort=_param(query, "sort", "heat"),
|
||||
sort=_param(query, "sort", "published"),
|
||||
within_days=_optional_int(query, "within_days"),
|
||||
year=_year_param(query),
|
||||
growth_days=_growth_days_param(query),
|
||||
@@ -403,7 +403,7 @@ border-color:#3a2c22;color:#f3e9dc}button{background:#e9b97c;color:#2a1a10}}
|
||||
scope = _param(query, "scope", "video")
|
||||
if scope == "up":
|
||||
self._send_json(HTTPStatus.OK, queries.list_ups(
|
||||
sort=_param(query, "sort", "efficiency"),
|
||||
sort=_param(query, "sort", "avg_views"),
|
||||
within_days=_optional_int(query, "within_days"),
|
||||
year=_year_param(query),
|
||||
q=_optional_str(query, "q"),
|
||||
@@ -419,7 +419,7 @@ border-color:#3a2c22;color:#f3e9dc}button{background:#e9b97c;color:#2a1a10}}
|
||||
if scope != "video":
|
||||
raise ApiError(HTTPStatus.BAD_REQUEST, "bad_request", "scope 必须是 video 或 up")
|
||||
self._send_json(HTTPStatus.OK, queries.list_videos(
|
||||
sort=_param(query, "sort", "heat"),
|
||||
sort=_param(query, "sort", "published"),
|
||||
within_days=_optional_int(query, "within_days"),
|
||||
year=_year_param(query),
|
||||
growth_days=_growth_days_param(query),
|
||||
@@ -435,7 +435,7 @@ border-color:#3a2c22;color:#f3e9dc}button{background:#e9b97c;color:#2a1a10}}
|
||||
return
|
||||
if path == "/api/ups":
|
||||
self._send_json(HTTPStatus.OK, queries.list_ups(
|
||||
sort=_param(query, "sort", "efficiency"),
|
||||
sort=_param(query, "sort", "avg_views"),
|
||||
within_days=_optional_int(query, "within_days"),
|
||||
year=_year_param(query),
|
||||
q=_optional_str(query, "q"),
|
||||
|
||||
@@ -225,7 +225,7 @@ function bindControls(root) {
|
||||
}
|
||||
|
||||
async function renderScope(root, { query }, scope) {
|
||||
const sort = query.get("sort") || "efficiency";
|
||||
const sort = query.get("sort") || (scope === "up" ? "avg_views" : "published");
|
||||
const within = query.get("within_days") || "";
|
||||
const year = query.get("year") || "";
|
||||
const growthDays = query.get("growth_days") || "7";
|
||||
|
||||
Reference in new issue
Block a user