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:
Dionisio
2026-02-16 09:17:54 +01:00
parent fb652c07e3
commit d6c4eb884d
17 changed files with 433 additions and 141 deletions
+20
View File
@@ -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,
}