initial statistics implementation
This commit is contained in:
@@ -1053,15 +1053,23 @@ export const clearLibraryCache = (): void => {
|
||||
currentLibraryId = null;
|
||||
};
|
||||
|
||||
// Library statistics endpoints
|
||||
export const statisticsApi = {
|
||||
getOverviewStatistics: async (libraryId: string): Promise<import('../types/api').LibraryOverviewStats> => {
|
||||
const response = await api.get(`/libraries/${libraryId}/statistics/overview`);
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
|
||||
// Image utility - now library-aware
|
||||
export const getImageUrl = (path: string): string => {
|
||||
if (!path) return '';
|
||||
|
||||
|
||||
// For compatibility during transition, handle both patterns
|
||||
if (path.startsWith('http')) {
|
||||
return path; // External URL
|
||||
}
|
||||
|
||||
|
||||
// Use library-aware API endpoint
|
||||
const libraryId = getCurrentLibraryId();
|
||||
return `/api/files/images/${libraryId}/${path}`;
|
||||
|
||||
@@ -204,4 +204,33 @@ export interface FilterPreset {
|
||||
description?: string;
|
||||
filters: Partial<AdvancedFilters>;
|
||||
category: 'length' | 'date' | 'rating' | 'reading' | 'content' | 'organization';
|
||||
}
|
||||
|
||||
// Library Statistics
|
||||
export interface LibraryOverviewStats {
|
||||
// Collection Overview
|
||||
totalStories: number;
|
||||
totalAuthors: number;
|
||||
totalSeries: number;
|
||||
totalTags: number;
|
||||
totalCollections: number;
|
||||
uniqueSourceDomains: number;
|
||||
|
||||
// Content Metrics
|
||||
totalWordCount: number;
|
||||
averageWordsPerStory: number;
|
||||
longestStory: StoryWordCount | null;
|
||||
shortestStory: StoryWordCount | null;
|
||||
|
||||
// Reading Time
|
||||
totalReadingTimeMinutes: number;
|
||||
averageReadingTimeMinutes: number;
|
||||
}
|
||||
|
||||
export interface StoryWordCount {
|
||||
id: string;
|
||||
title: string;
|
||||
authorName: string;
|
||||
wordCount: number;
|
||||
readingTimeMinutes: number;
|
||||
}
|
||||
Reference in New Issue
Block a user