feat: batch favorites endpoint + frontend dedup fixes
Backend: - Add POST /api/favorites/batch endpoint (single multi-row INSERT) - Add BatchFavoritesResult/BatchFavoritesStats DTOs - Add batch methods to ports, service, PG repository - Transaction-based insert with ON CONFLICT DO NOTHING, chunking at 5000 Frontend: - Rewrite batchFavorites() to single API call (40 requests → 1) - Add _replaceCacheFromResponse() to avoid extra GET round-trip - Centralize formatFileSize, isTextViewable, formatDateTime, formatDateShort - Remove duplicate icon mapping from app.js - Fix inconsistent quota defaults (10GB everywhere)
This commit is contained in:
@@ -78,3 +78,23 @@ impl FavoriteItemDto {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// Result DTO for batch add-to-favorites.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct BatchFavoritesResult {
|
||||
/// Statistics about the batch operation
|
||||
pub stats: BatchFavoritesStats,
|
||||
/// Full list of the user's favourites (enriched), so the client can
|
||||
/// replace its local cache in a single round-trip.
|
||||
pub favorites: Vec<FavoriteItemDto>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct BatchFavoritesStats {
|
||||
/// How many items were requested
|
||||
pub requested: usize,
|
||||
/// How many were actually inserted (new)
|
||||
pub inserted: u64,
|
||||
/// How many were already favourites (skipped)
|
||||
pub already_existed: u64,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user