refactor(server): remove sort by size in pg_acl_engine.rs (dead code)
This commit is contained in:
@@ -469,42 +469,6 @@ impl AuthorizationEngine for PgAclEngine {
|
|||||||
LIMIT $8"#
|
LIMIT $8"#
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
"size" => {
|
|
||||||
// Folders have no size — sentinel -1 (sorts first ASC, last DESC).
|
|
||||||
// Cursor encodes (sort_int=$5, resource_id=$7); $4/$6 unused.
|
|
||||||
let (where_clause, order_clause) = if reverse {
|
|
||||||
(
|
|
||||||
r#"( $5::bigint IS NULL
|
|
||||||
OR sort_int < $5
|
|
||||||
OR (sort_int = $5 AND resource_id < $7::uuid))"#,
|
|
||||||
"sort_int DESC, resource_id DESC",
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
(
|
|
||||||
r#"( $5::bigint IS NULL
|
|
||||||
OR sort_int > $5
|
|
||||||
OR (sort_int = $5 AND resource_id > $7::uuid))"#,
|
|
||||||
"sort_int ASC, resource_id ASC",
|
|
||||||
)
|
|
||||||
};
|
|
||||||
format!(
|
|
||||||
r#"WITH {AGG},
|
|
||||||
sized AS (
|
|
||||||
SELECT agg.*,
|
|
||||||
NULL::text AS sort_str,
|
|
||||||
CASE WHEN agg.resource_type = 'folder' THEN -1
|
|
||||||
ELSE fi.size
|
|
||||||
END AS sort_int
|
|
||||||
FROM agg
|
|
||||||
LEFT JOIN storage.files fi ON fi.id = agg.resource_id AND agg.resource_type = 'file'
|
|
||||||
)
|
|
||||||
SELECT resource_type, resource_id, permissions, granted_at, granted_by, sort_str, sort_int
|
|
||||||
FROM sized
|
|
||||||
WHERE {where_clause}
|
|
||||||
ORDER BY {order_clause}
|
|
||||||
LIMIT $8"#
|
|
||||||
)
|
|
||||||
}
|
|
||||||
_ => {
|
_ => {
|
||||||
// Default: sort by grant date.
|
// Default: sort by grant date.
|
||||||
// Normal = DESC (newest first); reversed = ASC (oldest first).
|
// Normal = DESC (newest first); reversed = ASC (oldest first).
|
||||||
@@ -588,14 +552,6 @@ impl AuthorizationEngine for PgAclEngine {
|
|||||||
sort_int: None,
|
sort_int: None,
|
||||||
reverse,
|
reverse,
|
||||||
},
|
},
|
||||||
"size" => GrantCursor {
|
|
||||||
sort_by: "size".to_owned(),
|
|
||||||
granted_at: r.3,
|
|
||||||
resource_id: r.1,
|
|
||||||
resource_name: None,
|
|
||||||
sort_int: r.6,
|
|
||||||
reverse,
|
|
||||||
},
|
|
||||||
_ => GrantCursor {
|
_ => GrantCursor {
|
||||||
sort_by: "granted_at".to_owned(),
|
sort_by: "granted_at".to_owned(),
|
||||||
granted_at: r.3,
|
granted_at: r.3,
|
||||||
|
|||||||
@@ -56,7 +56,9 @@ pub async fn get_favorites(
|
|||||||
auth_user: AuthUser,
|
auth_user: AuthUser,
|
||||||
) -> impl IntoResponse {
|
) -> impl IntoResponse {
|
||||||
let user_id = auth_user.id;
|
let user_id = auth_user.id;
|
||||||
warn!("Deprecated endpoint called: GET /api/favorites — use GET /api/favorites/resources instead");
|
warn!(
|
||||||
|
"Deprecated endpoint called: GET /api/favorites — use GET /api/favorites/resources instead"
|
||||||
|
);
|
||||||
|
|
||||||
match favorites_service.get_favorites(user_id).await {
|
match favorites_service.get_favorites(user_id).await {
|
||||||
Ok(favorites) => {
|
Ok(favorites) => {
|
||||||
|
|||||||
@@ -490,7 +490,9 @@ pub async fn list_folder_contents(
|
|||||||
auth_user: AuthUser,
|
auth_user: AuthUser,
|
||||||
path: Path<String>,
|
path: Path<String>,
|
||||||
) -> axum::response::Response {
|
) -> axum::response::Response {
|
||||||
tracing::warn!("Deprecated endpoint called: GET /api/folders/{{id}}/contents — use GET /api/folders/{{id}}/resources?resource_types=folder instead");
|
tracing::warn!(
|
||||||
|
"Deprecated endpoint called: GET /api/folders/{{id}}/contents — use GET /api/folders/{{id}}/resources?resource_types=folder instead"
|
||||||
|
);
|
||||||
FolderHandler::list_folder_contents_impl(state, auth_user, path).await
|
FolderHandler::list_folder_contents_impl(state, auth_user, path).await
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -534,7 +536,9 @@ pub async fn list_folder_contents_paginated(
|
|||||||
path: Path<String>,
|
path: Path<String>,
|
||||||
pagination: Query<PaginationRequestDto>,
|
pagination: Query<PaginationRequestDto>,
|
||||||
) -> axum::response::Response {
|
) -> axum::response::Response {
|
||||||
tracing::warn!("Deprecated endpoint called: GET /api/folders/{{id}}/contents/paginated — use GET /api/folders/{{id}}/resources instead");
|
tracing::warn!(
|
||||||
|
"Deprecated endpoint called: GET /api/folders/{{id}}/contents/paginated — use GET /api/folders/{{id}}/resources instead"
|
||||||
|
);
|
||||||
FolderHandler::list_folder_contents_paginated_impl(state, auth_user, path, pagination).await
|
FolderHandler::list_folder_contents_paginated_impl(state, auth_user, path, pagination).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -351,13 +351,10 @@ pub async fn list_shared_with_me(
|
|||||||
|
|
||||||
// Validate sort_by (defaults to "granted_at").
|
// Validate sort_by (defaults to "granted_at").
|
||||||
let sort_by = q.sort_by.as_deref().unwrap_or("granted_at");
|
let sort_by = q.sort_by.as_deref().unwrap_or("granted_at");
|
||||||
if !matches!(
|
if !matches!(sort_by, "granted_at" | "granted_by" | "name" | "type") {
|
||||||
sort_by,
|
|
||||||
"granted_at" | "granted_by" | "name" | "type" | "size"
|
|
||||||
) {
|
|
||||||
return (
|
return (
|
||||||
StatusCode::BAD_REQUEST,
|
StatusCode::BAD_REQUEST,
|
||||||
Json(serde_json::json!({"error": "invalid sort_by; valid values: granted_at, granted_by, name, type, size"})),
|
Json(serde_json::json!({"error": "invalid sort_by; valid values: granted_at, granted_by, name, type"})),
|
||||||
)
|
)
|
||||||
.into_response();
|
.into_response();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user