feat: Implement pagination for user media retrieval and update related structures

This commit is contained in:
2025-11-15 18:06:09 +01:00
parent dd10211c63
commit ccb9f09d4a
8 changed files with 144 additions and 47 deletions

View File

@@ -87,3 +87,37 @@ pub struct MediaImportBundle {
pub metadata_models: Vec<MediaMetadata>,
pub file_size: i64,
}
#[derive(Debug, Clone)]
pub struct PaginatedResponse<T> {
pub data: Vec<T>,
pub page: u32,
pub limit: u32,
pub total_items: i64,
pub total_pages: u32,
pub has_next_page: bool,
pub has_prev_page: bool,
}
impl<T> PaginatedResponse<T> {
pub fn new(data: Vec<T>, page: u32, limit: u32, total_items: i64) -> Self {
let total_pages = if limit == 0 {
0
} else {
(total_items as f64 / limit as f64).ceil() as u32
};
let has_next_page = page < total_pages;
let has_prev_page = page > 1;
Self {
data,
page,
limit,
total_items,
total_pages,
has_next_page,
has_prev_page,
}
}
}