Array of KenmeiManga entries.
Object containing total manga, status counts, volume data, average score, and total chapters read.
export function extractMangaMetadata(manga: KenmeiManga[]): {
totalManga: number;
statusCounts: Record<KenmeiStatus, number>;
hasVolumes: boolean;
averageScore: number;
totalChaptersRead: number;
} {
const statusCounts: Record<KenmeiStatus, number> = {
reading: 0,
completed: 0,
on_hold: 0,
dropped: 0,
plan_to_read: 0,
};
let totalScore = 0;
let scoredEntries = 0;
let totalChaptersRead = 0;
let hasVolumesData = false;
manga.forEach((entry) => {
// Count statuses
statusCounts[entry.status]++;
// Track scores
if (entry.score > 0) {
totalScore += entry.score;
scoredEntries++;
}
// Track chapters
totalChaptersRead += entry.chapters_read || 0;
// Check if we have volume data
if (entry.volumes_read !== undefined || entry.total_volumes !== undefined) {
hasVolumesData = true;
}
});
return {
totalManga: manga.length,
statusCounts,
hasVolumes: hasVolumesData,
averageScore: scoredEntries > 0 ? totalScore / scoredEntries : 0,
totalChaptersRead,
};
}
Extract unique metadata from manga entries. Useful for analyzing the dataset and providing statistics.