diff --git a/src/components/stats/DatesSheet.tsx b/src/components/stats/DatesSheet.tsx new file mode 100644 index 0000000..baf7eaa --- /dev/null +++ b/src/components/stats/DatesSheet.tsx @@ -0,0 +1,204 @@ +import { Check, X } from 'lucide-react' +import { useMemo, useState } from 'react' +import { locale, t } from '../../i18n' +import { useBackToClose } from '../../lib/backNav' +import { MEDIA_TYPES, TYPE_BY_VALUE } from '../../lib/constants' +import { approxPatch, bulkDays, dateQuality, endLabel, needsFix, type DateQuality } from '../../lib/dating' +import { useEscape } from '../../lib/escape' +import { useScrollLock } from '../../lib/scrollLock' +import { cx, formatDate } from '../../lib/utils' +import { useMedia } from '../../store' +import type { MediaItem, MediaType } from '../../types' +import Poster from '../Poster' + +type Tab = 'fix' | 'approx' + +/** + * « Dates à corriger » : les titres terminés dont la date de fin est celle d'un ajout en lot (ou absente). + * On en sélectionne plusieurs et on leur donne une année (et un mois si on s'en souvient), ou « je ne sais plus ». + */ +export default function DatesSheet({ onClose }: { onClose: () => void }) { + const { items, updateMany } = useMedia() + useScrollLock() + useEscape(onClose) + useBackToClose(onClose) + + // Les jours d'ajout en lot sont figés à l'ouverture : corriger une partie des titres ne fait pas « disparaître » le lot + const [bulk] = useState(() => bulkDays(items)) + const [tab, setTab] = useState('fix') + const [type, setType] = useState('') + const [selected, setSelected] = useState>(new Set()) + const [year, setYear] = useState('') + const [month, setMonth] = useState('') + const [busy, setBusy] = useState(false) + + const all = useMemo( + () => + items + .filter((i) => i.status === 'termine') + .map((i) => ({ item: i, q: dateQuality(i, bulk) })) + .filter(({ q }) => q !== 'exact'), + [items, bulk], + ) + const toFix = all.filter(({ q }) => needsFix(q)) + const approx = all.filter(({ q }) => !needsFix(q)) + const pool = tab === 'fix' ? toFix : approx + const types = MEDIA_TYPES.filter((m) => pool.some(({ item }) => item.type === m.value)) + // Filtre devenu vide (tous ses titres corrigés) : on revient à « Tout » + const activeType = type && types.some((m) => m.value === type) ? type : '' + const list = pool.filter(({ item }) => !activeType || item.type === activeType).sort((a, b) => a.item.title.localeCompare(b.item.title, locale())) + + const toggle = (id: string) => + setSelected((s) => { + const n = new Set(s) + if (n.has(id)) n.delete(id) + else n.add(id) + return n + }) + const allOn = list.length > 0 && list.every(({ item }) => selected.has(item.id)) + + const thisYear = new Date().getFullYear() + const years = Array.from({ length: thisYear - 1949 }, (_, k) => thisYear - k) + const months = Array.from({ length: 12 }, (_, k) => k + 1).filter((m) => Number(year) !== thisYear || m <= new Date().getMonth() + 1) + const monthName = (m: number) => new Date(2000, m - 1, 15).toLocaleDateString(locale(), { month: 'long' }) + + const apply = async (choice: { year: number; month?: number } | 'unknown') => { + const chosen = items.filter((i) => selected.has(i.id)) + if (!chosen.length) return + setBusy(true) + try { + await updateMany(chosen.map((i) => ({ id: i.id, patch: approxPatch(i, choice) }))) + setSelected(new Set()) + } finally { + setBusy(false) + } + } + + const statusText = (item: MediaItem, q: DateQuality) => + q === 'bulk' ? t('dates.bulk', { date: formatDate(item.endDate) }) : q === 'missing' ? t('dates.missing') : endLabel(item) + + return ( +
+
+
+
+ +

{t('dates.title')}

+ +
+
+ {(['fix', 'approx'] as const).map((x) => ( + + ))} +
+
+
+ +
+
+ {tab === 'fix' && toFix.length > 0 &&

{t('dates.hint')}

} + + {list.length > 0 && ( +
+ + {types.length > 1 && + types.map((m) => ( + + ))} + +
+ )} + + {list.length === 0 ? ( +

{tab === 'fix' ? t('dates.empty') : t('dates.emptyApprox')}

+ ) : ( +
    + {list.map(({ item, q }) => { + const on = selected.has(item.id) + return ( +
  • + +
  • + ) + })} +
+ )} +
+
+ + {/* Barre d'action : apparaît dès qu'un titre est sélectionné */} + {selected.size > 0 && ( +
+
+

{t('dates.selected', { count: selected.size })}

+
+ + +
+
+ + +
+
+
+ )} +
+ ) +} diff --git a/src/components/title/TitleSheet.tsx b/src/components/title/TitleSheet.tsx index 0600855..256b493 100644 --- a/src/components/title/TitleSheet.tsx +++ b/src/components/title/TitleSheet.tsx @@ -1,3 +1,4 @@ +import { approxPatch, endLabel } from '../../lib/dating' import { locale, t } from '../../i18n' import { Bookmark, Check, ChevronDown, Eye, Heart, Loader2, MessagesSquare, Minus, MoreHorizontal, Pencil, Play, Plus, Share2, Trash2, X } from 'lucide-react' import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react' @@ -183,11 +184,13 @@ export default function TitleSheet({ item: initial, seed, onClose, onGoToSetting if (s === status) return const patch: Partial = { status: s } const today = todayISO() - if (s === 'a_voir') Object.assign(patch, { startDate: undefined, endDate: undefined }) + if (s === 'a_voir') Object.assign(patch, { startDate: undefined, endDate: undefined, endApprox: undefined }) // Série : la date de début est celle du premier épisode coché - if (s === 'en_cours') Object.assign(patch, { startDate: episodic && !item?.episodesWatched ? item?.startDate : (item?.startDate ?? today), endDate: undefined }) + if (s === 'en_cours') Object.assign(patch, { startDate: episodic && !item?.episodesWatched ? item?.startDate : (item?.startDate ?? today), endDate: undefined, endApprox: undefined }) if (s === 'termine') { - patch.endDate = item?.status === 'termine' && item.endDate ? item.endDate : today + const keep = item?.status === 'termine' && item.endDate + patch.endDate = keep ? item.endDate : today + if (!keep) patch.endApprox = undefined if (!item?.startDate) patch.startDate = episodic && item?.episodesWatched ? today : patch.endDate const cap = episodeCap(item ?? { episodesTotal: data.episodesTotal, seasons: data.seasons }) if (episodic && cap) patch.episodesWatched = cap @@ -214,7 +217,8 @@ export default function TitleSheet({ item: initial, seed, onClose, onGoToSetting } // Date de fin seulement pour un titre terminé (noter une série en cours ne la termine pas) const finished = (patch.status ?? item?.status) === 'termine' - if (finished && !item?.endDate) patch.endDate = today + // (« date inconnue » choisie exprès : on ne la remplace pas) + if (finished && !item?.endDate && !item?.endApprox) patch.endDate = today if (finished && !item?.startDate) patch.startDate = today } void save(patch) @@ -769,7 +773,7 @@ function Tracking({ item, lists, tagSuggestions, onChange }: { item: MediaItem; const rewatches = [...(item.rewatchDates ?? [])].sort().reverse() const summary = [ item.startDate && `${t('form.startShort')} ${formatDate(item.startDate)}`, - item.endDate && `${t('form.endShort')} ${formatDate(item.endDate)}`, + endLabel(item) && `${t('form.endShort')} ${endLabel(item)}`, rewatches.length ? t('title.rewatchCount', { count: rewatches.length }) : undefined, ].filter(Boolean) @@ -789,10 +793,30 @@ function Tracking({ item, lists, tagSuggestions, onChange }: { item: MediaItem; {t('form.startShort')} onChange({ startDate: e.target.value || undefined })} /> - +
+ + {item.status === 'termine' && ( + + )} +
{t('lists.myLists')} diff --git a/src/i18n/locales/ar.ts b/src/i18n/locales/ar.ts index b9db6a4..de98663 100644 --- a/src/i18n/locales/ar.ts +++ b/src/i18n/locales/ar.ts @@ -1548,6 +1548,28 @@ const dict: Translations = { 'stats.avgLength': "متوسط المدة", 'stats.episodesSeen': "الحلقات المشاهدة", 'stats.decades': "عقود الإصدار", + // — Dates approximatives / ajouts en lot — + 'dates.title': "تواريخ تحتاج إلى تصحيح", + 'dates.open': "تصحيح التواريخ", + 'dates.openApprox': "عرض التواريخ التقريبية", + 'dates.chartNote': "خارج الرسم لعدم وجود تاريخ دقيق: {count}", + 'dates.tabFix': "للتصحيح", + 'dates.tabApprox': "تقريبية", + 'dates.bulk': "أُضيف دفعة واحدة في {date}", + 'dates.missing': "بلا تاريخ انتهاء", + 'dates.unknown': "تاريخ غير معروف", + 'dates.year': "حوالي {year}", + 'dates.approxLabel': "تقريبي", + 'dates.dunno': "لا أتذكر", + 'dates.selectAll': "تحديد الكل", + 'dates.selectNone': "إلغاء التحديد", + 'dates.selected': "المحدد: {count}", + 'dates.yearPh': "السنة", + 'dates.monthPh': "الشهر (اختياري)", + 'dates.apply': "تطبيق", + 'dates.empty': "كل شيء على ما يرام: لا توجد تواريخ للتصحيح.", + 'dates.emptyApprox': "لا توجد تواريخ تقريبية.", + 'dates.hint': "تم تعليم هذه الأعمال كمشاهدة في اليوم نفسه أثناء إضافة دفعة واحدة: تاريخ انتهائها هو يوم الإضافة لا يوم المشاهدة. حدّدها ثم اختر سنة (وشهرًا إن تذكرت)، أو «لا أتذكر».", } export default dict diff --git a/src/i18n/locales/de.ts b/src/i18n/locales/de.ts index 84d9be5..06d9ab0 100644 --- a/src/i18n/locales/de.ts +++ b/src/i18n/locales/de.ts @@ -1325,6 +1325,28 @@ const dict: Translations = { 'stats.avgLength': "Durchschnittliche Länge", 'stats.episodesSeen': "Gesehene Folgen", 'stats.decades': "Erscheinungsjahrzehnte", + // — Dates approximatives / ajouts en lot — + 'dates.title': "Zu korrigierende Daten", + 'dates.open': "Daten korrigieren", + 'dates.openApprox': "Ungefähre Daten ansehen", + 'dates.chartNote': "Ohne genaues Datum nicht im Diagramm: {count}", + 'dates.tabFix': "Zu korrigieren", + 'dates.tabApprox': "Ungefähr", + 'dates.bulk': "Gesammelt hinzugefügt am {date}", + 'dates.missing': "Kein Enddatum", + 'dates.unknown': "Datum unbekannt", + 'dates.year': "Um {year}", + 'dates.approxLabel': "ungefähr", + 'dates.dunno': "Weiß ich nicht mehr", + 'dates.selectAll': "Alle auswählen", + 'dates.selectNone': "Auswahl aufheben", + 'dates.selected': "Ausgewählt: {count}", + 'dates.yearPh': "Jahr", + 'dates.monthPh': "Monat (optional)", + 'dates.apply': "Übernehmen", + 'dates.empty': "Alles in Ordnung: keine Daten zu korrigieren.", + 'dates.emptyApprox': "Keine ungefähren Daten.", + 'dates.hint': "Diese Titel wurden am selben Tag beim gesammelten Hinzufügen als gesehen markiert: Ihr Enddatum ist der Tag des Hinzufügens, nicht des Ansehens. Wähle sie aus und gib ein Jahr (und einen Monat, falls du dich erinnerst) an – oder „Weiß ich nicht mehr“.", } export default dict diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts index d447ceb..33b6fa2 100644 --- a/src/i18n/locales/en.ts +++ b/src/i18n/locales/en.ts @@ -1325,6 +1325,28 @@ const dict: Translations = { 'stats.avgLength': "Average length", 'stats.episodesSeen': "Episodes watched", 'stats.decades': "Release decades", + // — Dates approximatives / ajouts en lot — + 'dates.title': "Dates to fix", + 'dates.open': "Fix dates", + 'dates.openApprox': "See approximate dates", + 'dates.chartNote': "Left out of the chart, no precise date: {count}", + 'dates.tabFix': "To fix", + 'dates.tabApprox': "Approximate", + 'dates.bulk': "Added in bulk on {date}", + 'dates.missing': "No end date", + 'dates.unknown': "Unknown date", + 'dates.year': "Around {year}", + 'dates.approxLabel': "approximate", + 'dates.dunno': "I don't remember", + 'dates.selectAll': "Select all", + 'dates.selectNone': "Deselect all", + 'dates.selected': "Selected: {count}", + 'dates.yearPh': "Year", + 'dates.monthPh': "Month (optional)", + 'dates.apply': "Apply", + 'dates.empty': "All good: no dates to fix.", + 'dates.emptyApprox': "No approximate dates.", + 'dates.hint': "These titles were marked as watched on the same day during a bulk add: their end date is the day they were added, not when you watched them. Select them, then pick a year (and a month if you remember), or “I don't remember”.", } export default dict diff --git a/src/i18n/locales/es.ts b/src/i18n/locales/es.ts index efa4afe..382e746 100644 --- a/src/i18n/locales/es.ts +++ b/src/i18n/locales/es.ts @@ -1325,6 +1325,28 @@ const dict: Translations = { 'stats.avgLength': "Duración media", 'stats.episodesSeen': "Episodios vistos", 'stats.decades': "Décadas de estreno", + // — Dates approximatives / ajouts en lot — + 'dates.title': "Fechas por corregir", + 'dates.open': "Corregir fechas", + 'dates.openApprox': "Ver fechas aproximadas", + 'dates.chartNote': "Fuera del gráfico, sin fecha precisa: {count}", + 'dates.tabFix': "Por corregir", + 'dates.tabApprox': "Aproximadas", + 'dates.bulk': "Añadido en bloque el {date}", + 'dates.missing': "Sin fecha de fin", + 'dates.unknown': "Fecha desconocida", + 'dates.year': "Hacia {year}", + 'dates.approxLabel': "aproximada", + 'dates.dunno': "No me acuerdo", + 'dates.selectAll': "Seleccionar todo", + 'dates.selectNone': "Deseleccionar todo", + 'dates.selected': "Seleccionados: {count}", + 'dates.yearPh': "Año", + 'dates.monthPh': "Mes (opcional)", + 'dates.apply': "Aplicar", + 'dates.empty': "Todo en orden: no hay fechas por corregir.", + 'dates.emptyApprox': "No hay fechas aproximadas.", + 'dates.hint': "Estos títulos se marcaron como vistos el mismo día al añadirlos en bloque: su fecha de fin es la del añadido, no la del visionado. Selecciónalos y elige un año (y un mes si lo recuerdas), o «No me acuerdo».", } export default dict diff --git a/src/i18n/locales/fr.ts b/src/i18n/locales/fr.ts index 7305d05..b1a4800 100644 --- a/src/i18n/locales/fr.ts +++ b/src/i18n/locales/fr.ts @@ -1327,6 +1327,28 @@ const dict = { 'stats.avgLength': "Durée moyenne", 'stats.episodesSeen': "Épisodes vus", 'stats.decades': "Décennies de sortie", + // — Dates approximatives / ajouts en lot — + 'dates.title': "Dates à corriger", + 'dates.open': "Corriger les dates", + 'dates.openApprox': "Voir les dates approximatives", + 'dates.chartNote': "Hors courbe, faute de date précise : {count}", + 'dates.tabFix': "À corriger", + 'dates.tabApprox': "Approximatives", + 'dates.bulk': "Ajouté en lot le {date}", + 'dates.missing': "Sans date de fin", + 'dates.unknown': "Date inconnue", + 'dates.year': "Vers {year}", + 'dates.approxLabel': "approximative", + 'dates.dunno': "Je ne sais plus", + 'dates.selectAll': "Tout sélectionner", + 'dates.selectNone': "Tout désélectionner", + 'dates.selected': "Sélectionnés : {count}", + 'dates.yearPh': "Année", + 'dates.monthPh': "Mois (facultatif)", + 'dates.apply': "Appliquer", + 'dates.empty': "Tout est en ordre : aucune date à corriger.", + 'dates.emptyApprox': "Aucune date approximative.", + 'dates.hint': "Ces titres ont été marqués « vus » le même jour, lors d'un ajout en lot : leur date de fin est celle de l'ajout, pas du visionnage. Sélectionne-les, puis choisis une année (et un mois si tu t'en souviens), ou « Je ne sais plus ».", } export default dict diff --git a/src/i18n/locales/hi.ts b/src/i18n/locales/hi.ts index 7911600..743e98c 100644 --- a/src/i18n/locales/hi.ts +++ b/src/i18n/locales/hi.ts @@ -1325,6 +1325,28 @@ const dict: Translations = { 'stats.avgLength': "औसत अवधि", 'stats.episodesSeen': "देखे गए एपिसोड", 'stats.decades': "रिलीज़ के दशक", + // — Dates approximatives / ajouts en lot — + 'dates.title': "सुधारने वाली तारीखें", + 'dates.open': "तारीखें सुधारें", + 'dates.openApprox': "अनुमानित तारीखें देखें", + 'dates.chartNote': "सटीक तारीख न होने से ग्राफ़ से बाहर: {count}", + 'dates.tabFix': "सुधारना है", + 'dates.tabApprox': "अनुमानित", + 'dates.bulk': "{date} को एक साथ जोड़ा गया", + 'dates.missing': "समाप्ति तारीख नहीं", + 'dates.unknown': "तारीख अज्ञात", + 'dates.year': "लगभग {year}", + 'dates.approxLabel': "अनुमानित", + 'dates.dunno': "याद नहीं", + 'dates.selectAll': "सभी चुनें", + 'dates.selectNone': "सभी हटाएँ", + 'dates.selected': "चुने गए: {count}", + 'dates.yearPh': "वर्ष", + 'dates.monthPh': "महीना (वैकल्पिक)", + 'dates.apply': "लागू करें", + 'dates.empty': "सब ठीक है: कोई तारीख सुधारनी नहीं।", + 'dates.emptyApprox': "कोई अनुमानित तारीख नहीं।", + 'dates.hint': "इन टाइटल को एक साथ जोड़ते समय एक ही दिन देखा गया चिह्नित किया गया था: इनकी समाप्ति तारीख जोड़ने का दिन है, देखने का नहीं। इन्हें चुनें, फिर एक वर्ष (और याद हो तो महीना) चुनें, या “याद नहीं”।", } export default dict diff --git a/src/i18n/locales/id.ts b/src/i18n/locales/id.ts index ff76e77..cac61f3 100644 --- a/src/i18n/locales/id.ts +++ b/src/i18n/locales/id.ts @@ -1325,6 +1325,28 @@ const dict: Translations = { 'stats.avgLength': "Durasi rata-rata", 'stats.episodesSeen': "Episode ditonton", 'stats.decades': "Dekade rilis", + // — Dates approximatives / ajouts en lot — + 'dates.title': "Tanggal yang perlu diperbaiki", + 'dates.open': "Perbaiki tanggal", + 'dates.openApprox': "Lihat tanggal perkiraan", + 'dates.chartNote': "Di luar grafik, tanpa tanggal pasti: {count}", + 'dates.tabFix': "Perlu diperbaiki", + 'dates.tabApprox': "Perkiraan", + 'dates.bulk': "Ditambahkan sekaligus pada {date}", + 'dates.missing': "Tanpa tanggal selesai", + 'dates.unknown': "Tanggal tidak diketahui", + 'dates.year': "Sekitar {year}", + 'dates.approxLabel': "perkiraan", + 'dates.dunno': "Aku lupa", + 'dates.selectAll': "Pilih semua", + 'dates.selectNone': "Batalkan pilihan", + 'dates.selected': "Dipilih: {count}", + 'dates.yearPh': "Tahun", + 'dates.monthPh': "Bulan (opsional)", + 'dates.apply': "Terapkan", + 'dates.empty': "Semua beres: tidak ada tanggal yang perlu diperbaiki.", + 'dates.emptyApprox': "Tidak ada tanggal perkiraan.", + 'dates.hint': "Judul-judul ini ditandai sudah ditonton pada hari yang sama saat ditambahkan sekaligus: tanggal selesainya adalah hari penambahan, bukan hari menonton. Pilih judulnya, lalu pilih tahun (dan bulan jika ingat), atau “Aku lupa”.", } export default dict diff --git a/src/i18n/locales/it.ts b/src/i18n/locales/it.ts index a265bd8..8b9e36b 100644 --- a/src/i18n/locales/it.ts +++ b/src/i18n/locales/it.ts @@ -1325,6 +1325,28 @@ const dict: Translations = { 'stats.avgLength': "Durata media", 'stats.episodesSeen': "Episodi visti", 'stats.decades': "Decenni di uscita", + // — Dates approximatives / ajouts en lot — + 'dates.title': "Date da correggere", + 'dates.open': "Correggi le date", + 'dates.openApprox': "Vedi le date approssimative", + 'dates.chartNote': "Fuori dal grafico, senza data precisa: {count}", + 'dates.tabFix': "Da correggere", + 'dates.tabApprox': "Approssimative", + 'dates.bulk': "Aggiunto in blocco il {date}", + 'dates.missing': "Senza data di fine", + 'dates.unknown': "Data sconosciuta", + 'dates.year': "Verso il {year}", + 'dates.approxLabel': "approssimativa", + 'dates.dunno': "Non ricordo", + 'dates.selectAll': "Seleziona tutto", + 'dates.selectNone': "Deseleziona tutto", + 'dates.selected': "Selezionati: {count}", + 'dates.yearPh': "Anno", + 'dates.monthPh': "Mese (facoltativo)", + 'dates.apply': "Applica", + 'dates.empty': "Tutto a posto: nessuna data da correggere.", + 'dates.emptyApprox': "Nessuna data approssimativa.", + 'dates.hint': "Questi titoli sono stati segnati come visti lo stesso giorno, durante un'aggiunta in blocco: la data di fine è quella dell'aggiunta, non della visione. Selezionali e scegli un anno (e un mese se lo ricordi), oppure «Non ricordo».", } export default dict diff --git a/src/i18n/locales/ja.ts b/src/i18n/locales/ja.ts index cee2988..b3a76f7 100644 --- a/src/i18n/locales/ja.ts +++ b/src/i18n/locales/ja.ts @@ -1325,6 +1325,28 @@ const dict: Translations = { 'stats.avgLength': "平均の長さ", 'stats.episodesSeen': "観たエピソード", 'stats.decades': "公開年代", + // — Dates approximatives / ajouts en lot — + 'dates.title': "修正が必要な日付", + 'dates.open': "日付を修正", + 'dates.openApprox': "おおよその日付を見る", + 'dates.chartNote': "正確な日付がないためグラフ外:{count}", + 'dates.tabFix': "要修正", + 'dates.tabApprox': "おおよそ", + 'dates.bulk': "{date} にまとめて追加", + 'dates.missing': "終了日なし", + 'dates.unknown': "日付不明", + 'dates.year': "{year}年ごろ", + 'dates.approxLabel': "おおよそ", + 'dates.dunno': "覚えていない", + 'dates.selectAll': "すべて選択", + 'dates.selectNone': "選択を解除", + 'dates.selected': "選択中:{count}", + 'dates.yearPh': "年", + 'dates.monthPh': "月(任意)", + 'dates.apply': "適用", + 'dates.empty': "問題ありません:修正する日付はありません。", + 'dates.emptyApprox': "おおよその日付はありません。", + 'dates.hint': "これらの作品はまとめて追加したときに同じ日に「視聴済み」になりました。終了日は追加した日で、実際に観た日ではありません。作品を選び、年(覚えていれば月も)を選ぶか、「覚えていない」を選んでください。", } export default dict diff --git a/src/i18n/locales/ko.ts b/src/i18n/locales/ko.ts index a45b983..e655715 100644 --- a/src/i18n/locales/ko.ts +++ b/src/i18n/locales/ko.ts @@ -1325,6 +1325,28 @@ const dict: Translations = { 'stats.avgLength': "평균 길이", 'stats.episodesSeen': "본 에피소드", 'stats.decades': "개봉 연대", + // — Dates approximatives / ajouts en lot — + 'dates.title': "수정할 날짜", + 'dates.open': "날짜 수정", + 'dates.openApprox': "대략적인 날짜 보기", + 'dates.chartNote': "정확한 날짜가 없어 그래프에서 제외: {count}", + 'dates.tabFix': "수정 필요", + 'dates.tabApprox': "대략적", + 'dates.bulk': "{date}에 한꺼번에 추가됨", + 'dates.missing': "종료일 없음", + 'dates.unknown': "날짜 모름", + 'dates.year': "{year}년쯤", + 'dates.approxLabel': "대략적", + 'dates.dunno': "기억 안 나요", + 'dates.selectAll': "모두 선택", + 'dates.selectNone': "선택 해제", + 'dates.selected': "선택됨: {count}", + 'dates.yearPh': "연도", + 'dates.monthPh': "월(선택)", + 'dates.apply': "적용", + 'dates.empty': "모두 정상이에요: 수정할 날짜가 없어요.", + 'dates.emptyApprox': "대략적인 날짜가 없어요.", + 'dates.hint': "이 작품들은 한꺼번에 추가할 때 같은 날 '봤음'으로 표시됐어요. 종료일은 실제로 본 날이 아니라 추가한 날이에요. 작품을 선택한 뒤 연도(기억나면 월도)를 고르거나 '기억 안 나요'를 누르세요.", } export default dict diff --git a/src/i18n/locales/nl.ts b/src/i18n/locales/nl.ts index 281d73f..49b003c 100644 --- a/src/i18n/locales/nl.ts +++ b/src/i18n/locales/nl.ts @@ -1325,6 +1325,28 @@ const dict: Translations = { 'stats.avgLength': "Gemiddelde duur", 'stats.episodesSeen': "Geziene afleveringen", 'stats.decades': "Decennia van uitgave", + // — Dates approximatives / ajouts en lot — + 'dates.title': "Te corrigeren datums", + 'dates.open': "Datums corrigeren", + 'dates.openApprox': "Geschatte datums bekijken", + 'dates.chartNote': "Buiten de grafiek, geen precieze datum: {count}", + 'dates.tabFix': "Te corrigeren", + 'dates.tabApprox': "Geschat", + 'dates.bulk': "In bulk toegevoegd op {date}", + 'dates.missing': "Geen einddatum", + 'dates.unknown': "Datum onbekend", + 'dates.year': "Rond {year}", + 'dates.approxLabel': "geschat", + 'dates.dunno': "Weet ik niet meer", + 'dates.selectAll': "Alles selecteren", + 'dates.selectNone': "Alles deselecteren", + 'dates.selected': "Geselecteerd: {count}", + 'dates.yearPh': "Jaar", + 'dates.monthPh': "Maand (optioneel)", + 'dates.apply': "Toepassen", + 'dates.empty': "Alles in orde: geen datums te corrigeren.", + 'dates.emptyApprox': "Geen geschatte datums.", + 'dates.hint': "Deze titels zijn op dezelfde dag als gezien gemarkeerd bij een bulktoevoeging: hun einddatum is de dag van toevoegen, niet van kijken. Selecteer ze en kies een jaar (en een maand als je die nog weet), of ‘Weet ik niet meer’.", } export default dict diff --git a/src/i18n/locales/pl.ts b/src/i18n/locales/pl.ts index 52b533d..7d4367d 100644 --- a/src/i18n/locales/pl.ts +++ b/src/i18n/locales/pl.ts @@ -1465,6 +1465,28 @@ const dict: Translations = { 'stats.avgLength': "Średnia długość", 'stats.episodesSeen': "Obejrzane odcinki", 'stats.decades': "Dekady premiery", + // — Dates approximatives / ajouts en lot — + 'dates.title': "Daty do poprawienia", + 'dates.open': "Popraw daty", + 'dates.openApprox': "Zobacz przybliżone daty", + 'dates.chartNote': "Poza wykresem, bez dokładnej daty: {count}", + 'dates.tabFix': "Do poprawienia", + 'dates.tabApprox': "Przybliżone", + 'dates.bulk': "Dodane hurtowo {date}", + 'dates.missing': "Brak daty zakończenia", + 'dates.unknown': "Data nieznana", + 'dates.year': "Około {year}", + 'dates.approxLabel': "przybliżona", + 'dates.dunno': "Nie pamiętam", + 'dates.selectAll': "Zaznacz wszystko", + 'dates.selectNone': "Odznacz wszystko", + 'dates.selected': "Zaznaczone: {count}", + 'dates.yearPh': "Rok", + 'dates.monthPh': "Miesiąc (opcjonalnie)", + 'dates.apply': "Zastosuj", + 'dates.empty': "Wszystko w porządku: brak dat do poprawienia.", + 'dates.emptyApprox': "Brak przybliżonych dat.", + 'dates.hint': "Te tytuły oznaczono jako obejrzane tego samego dnia podczas hurtowego dodawania: ich data zakończenia to dzień dodania, a nie oglądania. Zaznacz je i wybierz rok (oraz miesiąc, jeśli pamiętasz) albo „Nie pamiętam”.", } export default dict diff --git a/src/i18n/locales/pt.ts b/src/i18n/locales/pt.ts index a6c083a..bce57cf 100644 --- a/src/i18n/locales/pt.ts +++ b/src/i18n/locales/pt.ts @@ -1325,6 +1325,28 @@ const dict: Translations = { 'stats.avgLength': "Duração média", 'stats.episodesSeen': "Episódios vistos", 'stats.decades': "Décadas de estreia", + // — Dates approximatives / ajouts en lot — + 'dates.title': "Datas a corrigir", + 'dates.open': "Corrigir datas", + 'dates.openApprox': "Ver datas aproximadas", + 'dates.chartNote': "Fora do gráfico, sem data precisa: {count}", + 'dates.tabFix': "A corrigir", + 'dates.tabApprox': "Aproximadas", + 'dates.bulk': "Adicionado em lote a {date}", + 'dates.missing': "Sem data de fim", + 'dates.unknown': "Data desconhecida", + 'dates.year': "Por volta de {year}", + 'dates.approxLabel': "aproximada", + 'dates.dunno': "Não me lembro", + 'dates.selectAll': "Selecionar tudo", + 'dates.selectNone': "Desmarcar tudo", + 'dates.selected': "Selecionados: {count}", + 'dates.yearPh': "Ano", + 'dates.monthPh': "Mês (opcional)", + 'dates.apply': "Aplicar", + 'dates.empty': "Tudo certo: nenhuma data a corrigir.", + 'dates.emptyApprox': "Nenhuma data aproximada.", + 'dates.hint': "Estes títulos foram marcados como vistos no mesmo dia, ao adicionar em lote: a data de fim é a do registo, não a do visionamento. Seleciona-os e escolhe um ano (e um mês, se te lembrares), ou «Não me lembro».", } export default dict diff --git a/src/i18n/locales/ru.ts b/src/i18n/locales/ru.ts index 954569f..523bee3 100644 --- a/src/i18n/locales/ru.ts +++ b/src/i18n/locales/ru.ts @@ -1465,6 +1465,28 @@ const dict: Translations = { 'stats.avgLength': "Средняя длительность", 'stats.episodesSeen': "Просмотрено серий", 'stats.decades': "Десятилетия выхода", + // — Dates approximatives / ajouts en lot — + 'dates.title': "Даты для исправления", + 'dates.open': "Исправить даты", + 'dates.openApprox': "Посмотреть приблизительные даты", + 'dates.chartNote': "Вне графика, без точной даты: {count}", + 'dates.tabFix': "Исправить", + 'dates.tabApprox': "Приблизительные", + 'dates.bulk': "Добавлено пакетом {date}", + 'dates.missing': "Нет даты окончания", + 'dates.unknown': "Дата неизвестна", + 'dates.year': "Около {year}", + 'dates.approxLabel': "приблизительно", + 'dates.dunno': "Не помню", + 'dates.selectAll': "Выбрать все", + 'dates.selectNone': "Снять выбор", + 'dates.selected': "Выбрано: {count}", + 'dates.yearPh': "Год", + 'dates.monthPh': "Месяц (необязательно)", + 'dates.apply': "Применить", + 'dates.empty': "Всё в порядке: исправлять нечего.", + 'dates.emptyApprox': "Нет приблизительных дат.", + 'dates.hint': "Эти тайтлы были отмечены просмотренными в один день при пакетном добавлении: их дата окончания — день добавления, а не просмотра. Выбери их и укажи год (и месяц, если помнишь) или «Не помню».", } export default dict diff --git a/src/i18n/locales/th.ts b/src/i18n/locales/th.ts index 1913999..e1eb730 100644 --- a/src/i18n/locales/th.ts +++ b/src/i18n/locales/th.ts @@ -1325,6 +1325,28 @@ const dict: Translations = { 'stats.avgLength': "ความยาวเฉลี่ย", 'stats.episodesSeen': "ตอนที่ดู", 'stats.decades': "ทศวรรษที่ออกฉาย", + // — Dates approximatives / ajouts en lot — + 'dates.title': "วันที่ที่ต้องแก้", + 'dates.open': "แก้วันที่", + 'dates.openApprox': "ดูวันที่โดยประมาณ", + 'dates.chartNote': "ไม่อยู่ในกราฟเพราะไม่มีวันที่แน่ชัด: {count}", + 'dates.tabFix': "ต้องแก้", + 'dates.tabApprox': "โดยประมาณ", + 'dates.bulk': "เพิ่มพร้อมกันเมื่อ {date}", + 'dates.missing': "ไม่มีวันที่ดูจบ", + 'dates.unknown': "ไม่ทราบวันที่", + 'dates.year': "ราว {year}", + 'dates.approxLabel': "โดยประมาณ", + 'dates.dunno': "จำไม่ได้", + 'dates.selectAll': "เลือกทั้งหมด", + 'dates.selectNone': "ยกเลิกการเลือก", + 'dates.selected': "เลือกแล้ว: {count}", + 'dates.yearPh': "ปี", + 'dates.monthPh': "เดือน (ไม่บังคับ)", + 'dates.apply': "ใช้", + 'dates.empty': "เรียบร้อย: ไม่มีวันที่ที่ต้องแก้", + 'dates.emptyApprox': "ไม่มีวันที่โดยประมาณ", + 'dates.hint': "เรื่องเหล่านี้ถูกทำเครื่องหมายว่าดูแล้วในวันเดียวกันตอนเพิ่มพร้อมกัน วันที่ดูจบจึงเป็นวันที่เพิ่ม ไม่ใช่วันที่ดูจริง เลือกเรื่อง แล้วเลือกปี (และเดือนถ้าจำได้) หรือ “จำไม่ได้”", } export default dict diff --git a/src/i18n/locales/tr.ts b/src/i18n/locales/tr.ts index a1def1f..14bbb4b 100644 --- a/src/i18n/locales/tr.ts +++ b/src/i18n/locales/tr.ts @@ -1325,6 +1325,28 @@ const dict: Translations = { 'stats.avgLength': "Ortalama süre", 'stats.episodesSeen': "İzlenen bölümler", 'stats.decades': "Yayın on yılları", + // — Dates approximatives / ajouts en lot — + 'dates.title': "Düzeltilecek tarihler", + 'dates.open': "Tarihleri düzelt", + 'dates.openApprox': "Yaklaşık tarihleri gör", + 'dates.chartNote': "Kesin tarihi olmadığı için grafik dışı: {count}", + 'dates.tabFix': "Düzeltilecek", + 'dates.tabApprox': "Yaklaşık", + 'dates.bulk': "Toplu eklendi: {date}", + 'dates.missing': "Bitiş tarihi yok", + 'dates.unknown': "Tarih bilinmiyor", + 'dates.year': "{year} civarı", + 'dates.approxLabel': "yaklaşık", + 'dates.dunno': "Hatırlamıyorum", + 'dates.selectAll': "Tümünü seç", + 'dates.selectNone': "Seçimi kaldır", + 'dates.selected': "Seçilen: {count}", + 'dates.yearPh': "Yıl", + 'dates.monthPh': "Ay (isteğe bağlı)", + 'dates.apply': "Uygula", + 'dates.empty': "Her şey yolunda: düzeltilecek tarih yok.", + 'dates.emptyApprox': "Yaklaşık tarih yok.", + 'dates.hint': "Bu yapımlar toplu eklemede aynı gün izlendi olarak işaretlendi: bitiş tarihleri izleme değil ekleme günü. Onları seç, sonra bir yıl (hatırlıyorsan ay da) seç ya da “Hatırlamıyorum”a dokun.", } export default dict diff --git a/src/i18n/locales/vi.ts b/src/i18n/locales/vi.ts index 80f99b5..b86ed0a 100644 --- a/src/i18n/locales/vi.ts +++ b/src/i18n/locales/vi.ts @@ -1325,6 +1325,28 @@ const dict: Translations = { 'stats.avgLength': "Thời lượng trung bình", 'stats.episodesSeen': "Tập đã xem", 'stats.decades': "Thập niên phát hành", + // — Dates approximatives / ajouts en lot — + 'dates.title': "Ngày cần sửa", + 'dates.open': "Sửa ngày", + 'dates.openApprox': "Xem ngày ước lượng", + 'dates.chartNote': "Không có trong biểu đồ vì thiếu ngày chính xác: {count}", + 'dates.tabFix': "Cần sửa", + 'dates.tabApprox': "Ước lượng", + 'dates.bulk': "Thêm hàng loạt ngày {date}", + 'dates.missing': "Không có ngày xem xong", + 'dates.unknown': "Không rõ ngày", + 'dates.year': "Khoảng {year}", + 'dates.approxLabel': "ước lượng", + 'dates.dunno': "Không nhớ", + 'dates.selectAll': "Chọn tất cả", + 'dates.selectNone': "Bỏ chọn tất cả", + 'dates.selected': "Đã chọn: {count}", + 'dates.yearPh': "Năm", + 'dates.monthPh': "Tháng (không bắt buộc)", + 'dates.apply': "Áp dụng", + 'dates.empty': "Mọi thứ ổn: không có ngày nào cần sửa.", + 'dates.emptyApprox': "Không có ngày ước lượng.", + 'dates.hint': "Các phim này được đánh dấu đã xem cùng một ngày khi thêm hàng loạt: ngày xem xong là ngày thêm vào, không phải ngày xem. Hãy chọn chúng rồi chọn năm (và tháng nếu còn nhớ), hoặc “Không nhớ”.", } export default dict diff --git a/src/i18n/locales/zh.ts b/src/i18n/locales/zh.ts index ce11802..29f538f 100644 --- a/src/i18n/locales/zh.ts +++ b/src/i18n/locales/zh.ts @@ -1325,6 +1325,28 @@ const dict: Translations = { 'stats.avgLength': "平均时长", 'stats.episodesSeen': "看过的集数", 'stats.decades': "上映年代", + // — Dates approximatives / ajouts en lot — + 'dates.title': "需要修正的日期", + 'dates.open': "修正日期", + 'dates.openApprox': "查看大致日期", + 'dates.chartNote': "没有准确日期,未计入图表:{count}", + 'dates.tabFix': "待修正", + 'dates.tabApprox': "大致", + 'dates.bulk': "于 {date} 批量添加", + 'dates.missing': "无看完日期", + 'dates.unknown': "日期未知", + 'dates.year': "约 {year} 年", + 'dates.approxLabel': "大致", + 'dates.dunno': "不记得了", + 'dates.selectAll': "全选", + 'dates.selectNone': "取消全选", + 'dates.selected': "已选:{count}", + 'dates.yearPh': "年份", + 'dates.monthPh': "月份(可选)", + 'dates.apply': "应用", + 'dates.empty': "一切正常:没有需要修正的日期。", + 'dates.emptyApprox': "没有大致日期。", + 'dates.hint': "这些作品是在批量添加时于同一天被标记为看过的:它们的看完日期是添加的日子,而不是观看的日子。选中它们,然后选择年份(记得的话再选月份),或选择“不记得了”。", } export default dict diff --git a/src/lib/backup.ts b/src/lib/backup.ts index 8e49d40..ec847f3 100644 --- a/src/lib/backup.ts +++ b/src/lib/backup.ts @@ -119,6 +119,7 @@ export function normalizeItem(raw: unknown): MediaItem | null { duration: int(r.duration, 0, 6000) || undefined, startDate: safeDay(r.startDate), endDate: safeDay(r.endDate), + endApprox: r.endApprox === 'year' || r.endApprox === 'month' || r.endApprox === 'unknown' ? r.endApprox : undefined, genres: safeStringList(r.genres, LIMITS.genres), platform: cleanText(r.platform, LIMITS.shortText), notes: cleanText(r.notes, LIMITS.notes), diff --git a/src/lib/dating.ts b/src/lib/dating.ts new file mode 100644 index 0000000..f143dd0 --- /dev/null +++ b/src/lib/dating.ts @@ -0,0 +1,80 @@ +import { locale, t } from '../i18n' +import type { MediaItem } from '../types' +import { formatDate, todayISO } from './utils' + +/** + * Qualité de la date de fin d'un titre terminé. + * + * Quand on ajoute toute sa bibliothèque d'un coup (import, ou des dizaines de titres « vus » le même jour), + * la date de fin enregistrée est celle de l'ajout, pas du visionnage : la courbe des stats serait fausse. + * Ces « ajouts en lot » sont repérés automatiquement et tenus à l'écart de la courbe, jusqu'à ce que je + * corrige la date (année, mois, ou « je ne sais plus »). + */ +export type DateQuality = 'exact' | 'month' | 'year' | 'unknown' | 'bulk' | 'missing' + +/** À partir de combien de titres terminés le même jour on considère que c'est un ajout en lot. */ +export const BULK_MIN = 15 + +const localDay = (iso: string) => { + const d = new Date(iso) + return Number.isNaN(d.getTime()) ? iso.slice(0, 10) : `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}` +} + +/** + * Jours d'ajout en lot : beaucoup de titres créés le même jour, ou beaucoup de titres « terminés » le même jour. + * Compter aussi les créations garde le lot reconnu quand on a déjà corrigé une partie de ses titres. + */ +export function bulkDays(items: MediaItem[]): Set { + const ends = new Map() + const created = new Map() + for (const i of items) { + const c = localDay(i.createdAt) + created.set(c, (created.get(c) ?? 0) + 1) + if (i.status === 'termine' && !i.endApprox && i.endDate) ends.set(i.endDate, (ends.get(i.endDate) ?? 0) + 1) + } + const out = new Set() + for (const m of [ends, created]) for (const [d, n] of m) if (n >= BULK_MIN) out.add(d) + return out +} + +export function dateQuality(item: MediaItem, bulk: Set): DateQuality { + // Seule la date de fin d'un titre terminé compte ici (les autres statuts se rattachent à leur début) + if (item.status !== 'termine') return 'exact' + if (item.endApprox === 'unknown') return 'unknown' + if (item.endApprox === 'year') return 'year' + if (item.endApprox === 'month') return 'month' + if (!item.endDate) return 'missing' + return bulk.has(item.endDate) ? 'bulk' : 'exact' +} + +/** Date à corriger (ajout en lot ou aucune date). */ +export const needsFix = (q: DateQuality) => q === 'bulk' || q === 'missing' +/** Peut aller dans la courbe mois par mois. */ +export const knowsMonth = (q: DateQuality) => q === 'exact' || q === 'month' +/** Peut compter pour une année. */ +export const knowsYear = (q: DateQuality) => q === 'exact' || q === 'month' || q === 'year' + +/** + * Correctif pour une date approximative : année seule (→ 1er juillet), année + mois (→ le 15), + * ou inconnue (date effacée). La date de début, si elle venait du même ajout en lot, est effacée aussi. + */ +export function approxPatch(item: MediaItem, choice: { year: number; month?: number } | 'unknown'): Pick { + const today = todayISO() + if (choice === 'unknown') { + return { endDate: undefined, endApprox: 'unknown', startDate: item.startDate && item.startDate === item.endDate ? undefined : item.startDate } + } + const raw = choice.month ? `${choice.year}-${String(choice.month).padStart(2, '0')}-15` : `${choice.year}-07-01` + const endDate = raw > today ? today : raw + // Un début postérieur à la nouvelle fin (ou identique à l'ancienne fin factice) n'a plus de sens + const startDate = item.startDate && (item.startDate > endDate || item.startDate === item.endDate) ? undefined : item.startDate + return { endDate, endApprox: choice.month ? 'month' : 'year', startDate } +} + +/** Date de fin telle qu'on l'affiche : « 12 mars 2024 », « mars 2023 », « vers 2021 », « date inconnue ». */ +export function endLabel(item: MediaItem): string | undefined { + if (item.endApprox === 'unknown') return t('dates.unknown') + if (!item.endDate) return undefined + if (item.endApprox === 'year') return t('dates.year', { year: item.endDate.slice(0, 4) }) + if (item.endApprox === 'month') return new Date(item.endDate + 'T12:00:00').toLocaleDateString(locale(), { month: 'long', year: 'numeric' }) + return formatDate(item.endDate) +} diff --git a/src/lib/stats.ts b/src/lib/stats.ts index d10c58b..7e65d50 100644 --- a/src/lib/stats.ts +++ b/src/lib/stats.ts @@ -2,6 +2,7 @@ import { locale } from '../i18n' import type { MediaItem, MediaType, WatchStatus } from '../types' import { episodeCap } from './franchise' import { DEFAULT_FILM_MINUTES, MEDIA_TYPES, STATUSES, TYPE_BY_VALUE } from './constants' +import { dateQuality, knowsMonth, knowsYear } from './dating' /** Temps estimé (minutes) passé sur une fiche. */ export function watchMinutes(item: MediaItem): number { @@ -110,15 +111,15 @@ export function watchDate(item: MediaItem): string | undefined { return item.startDate ?? item.updatedAt.slice(0, 10) } -/** Années pour lesquelles j'ai des visionnages, de la plus récente à la plus ancienne. */ -export function availableYears(items: MediaItem[]): string[] { - return [...new Set(items.map((i) => watchDate(i)?.slice(0, 4)).filter((y): y is string => !!y))].sort().reverse() +/** Années pour lesquelles j'ai des visionnages, de la plus récente à la plus ancienne (dates d'ajout en lot exclues). */ +export function availableYears(items: MediaItem[], bulk: Set = new Set()): string[] { + return [...new Set(items.filter((i) => knowsYear(dateQuality(i, bulk))).map((i) => watchDate(i)?.slice(0, 4)).filter((y): y is string => !!y))].sort().reverse() } -/** Garde les fiches rattachées à l'année (ou toutes si year = ''). « À voir » compte toujours. */ -export function itemsForPeriod(items: MediaItem[], year: string): MediaItem[] { +/** Garde les fiches rattachées à l'année (ou toutes si year = ''). Un titre sans année fiable n'entre dans aucune année. */ +export function itemsForPeriod(items: MediaItem[], year: string, bulk: Set = new Set()): MediaItem[] { if (!year) return items - return items.filter((i) => watchDate(i)?.startsWith(year)) + return items.filter((i) => knowsYear(dateQuality(i, bulk)) && watchDate(i)?.startsWith(year)) } export interface MonthBucket { @@ -130,7 +131,7 @@ export interface MonthBucket { } /** Titres terminés et temps par mois : les 12 mois de l'année choisie, ou les 12 derniers mois. */ -export function monthly(items: MediaItem[], year: string): MonthBucket[] { +export function monthly(items: MediaItem[], year: string, bulk: Set = new Set()): MonthBucket[] { const months: string[] = [] if (year) { for (let m = 1; m <= 12; m++) months.push(`${year}-${String(m).padStart(2, '0')}`) @@ -144,7 +145,7 @@ export function monthly(items: MediaItem[], year: string): MonthBucket[] { } return months.map((key) => { const date = new Date(`${key}-15T12:00:00`) - const inMonth = items.filter((i) => i.status === 'termine' && watchDate(i)?.startsWith(key)) + const inMonth = items.filter((i) => i.status === 'termine' && knowsMonth(dateQuality(i, bulk)) && watchDate(i)?.startsWith(key)) const label = date.toLocaleDateString(locale(), { month: 'short' }) return { key, diff --git a/src/pages/StatsPage.tsx b/src/pages/StatsPage.tsx index 05f3c6d..86c1917 100644 --- a/src/pages/StatsPage.tsx +++ b/src/pages/StatsPage.tsx @@ -2,6 +2,8 @@ import { useMemo, useState } from 'react' import { t } from '../i18n' import { BarList, Columns, Panel, StatTile } from '../components/stats/Charts' import Poster from '../components/Poster' +import DatesSheet from '../components/stats/DatesSheet' +import { bulkDays, dateQuality, knowsMonth, needsFix } from '../lib/dating' import { EmptyState, PageHeader } from '../components/ui' import { STATUSES, TYPE_BY_VALUE } from '../lib/constants' import { genreLabel } from '../lib/genres' @@ -26,11 +28,14 @@ export default function StatsPage({ onOpen }: { onOpen: (item: MediaItem) => voi const { items, settings } = useMedia() const [scope, setScope] = useState('all') const [year, setYear] = useState('') + const [fixing, setFixing] = useState(false) + // Jours d'ajout en lot, repérés sur toute la bibliothèque + const bulk = useMemo(() => bulkDays(items), [items]) const scoped = useMemo(() => (scope === 'all' ? items : items.filter((i) => SCOPE_TYPES[scope].includes(i.type))), [items, scope]) - const years = useMemo(() => availableYears(scoped), [scoped]) + const years = useMemo(() => availableYears(scoped, bulk), [scoped, bulk]) const period = year && years.includes(year) ? year : '' - const list = useMemo(() => itemsForPeriod(scoped, period), [scoped, period]) + const list = useMemo(() => itemsForPeriod(scoped, period, bulk), [scoped, period, bulk]) // Onglets : « Général », « Films », « Séries » toujours ; les autres seulement s'ils ont des titres const scopes: Scope[] = (['all', 'film', 'series', 'anime', 'other'] as Scope[]).filter( @@ -66,15 +71,44 @@ export default function StatsPage({ onOpen }: { onOpen: (item: MediaItem) => voi {list.length === 0 ? ( ) : ( - + setFixing(true)} /> )} + {fixing && setFixing(false)} />} ) } -function StatsBody({ scope, items, year, scale, onOpen }: { scope: Scope; items: MediaItem[]; year: string; scale: '5' | '10'; onOpen: (item: MediaItem) => void }) { +function StatsBody({ + scope, + items, + year, + bulk, + scale, + onOpen, + onFixDates, +}: { + scope: Scope + items: MediaItem[] + year: string + bulk: Set + scale: '5' | '10' + onOpen: (item: MediaItem) => void + onFixDates: () => void +}) { const s = useMemo(() => computeStats(items), [items]) - const months = useMemo(() => monthly(items, year), [items, year]) + const months = useMemo(() => monthly(items, year, bulk), [items, year, bulk]) + // Titres terminés tenus à l'écart de la courbe (ajout en lot, sans date, ou date trop vague) + const offChart = useMemo(() => { + let n = 0 + let fix = 0 + for (const i of items) { + if (i.status !== 'termine') continue + const q = dateQuality(i, bulk) + if (!knowsMonth(q)) n++ + if (needsFix(q)) fix++ + } + return { n, fix } + }, [items, bulk]) const rec = useMemo(() => records(items), [items]) const geo = useMemo(() => countries(items), [items]) const isFilm = scope === 'film' @@ -142,6 +176,14 @@ function StatsBody({ scope, items, year, scale, onOpen }: { scope: Scope; items: {t('stats.busiest')} {busiest.label} · {t('stats.monthFinished', { count: busiest.count })}

)} + {offChart.n > 0 && ( +
+

{t('dates.chartNote', { count: offChart.n })}

+ +
+ )} {/* Temps par type (vue générale, et séries quand il y a plusieurs formats) */} diff --git a/src/types.ts b/src/types.ts index cb60469..2513344 100644 --- a/src/types.ts +++ b/src/types.ts @@ -33,6 +33,8 @@ export interface MediaItem { startDate?: string // AAAA-MM-JJ endDate?: string // AAAA-MM-JJ + /** Date de fin approximative : année seule, mois, ou inconnue (titres ajoutés en lot, vus il y a longtemps). */ + endApprox?: 'year' | 'month' | 'unknown' genres: string[] platform?: string /** Mon avis (visible sur mon profil, comme ma note) */