Real-account read check of the desktop tabs: analytics snapshot stops when every store failed, compare names why a store has no days (Growth shows it), listing screenshot count skips contact sheets; Growth chart as an index on one axis; recorded price answers round-trip the price sheet

This commit is contained in:
CRTkafa 2026-10-11 00:06:26 +00:00
parent ffe64c5648
commit c2b0a0d8a3
15 changed files with 468 additions and 31 deletions

View file

@ -125,6 +125,30 @@ export interface Snapshot {
play?: { daily: PlayDay[]; totals: Totals } | { error: string };
}
/**
* Why a fresh snapshot is not worth writing: every store it read failed (no ONGOING report request yet, no reports
* bucket, no access). Null when at least one store has days. A snapshot of errors only would make `snapshot` look done
* while `compare` and the desktop chart stay empty.
*/
export function snapshotProblem(s: Snapshot): string | null {
const parts = (['apple', 'play'] as const).filter(k => s[k]);
if (!parts.length) return 'no store to read (no apple or play section in the config, or --store names none)';
if (parts.some(k => !('error' in s[k]!))) return null;
return parts.map(k => `${k}: ${(s[k] as { error: string }).error}`).join('; ');
}
/** The newest error per store when that store has no days in any snapshot (shown instead of an empty chart). */
export function storeErrors(snaps: Snapshot[]): { apple?: string; play?: string } {
const out: { apple?: string; play?: string } = {};
const series = mergeSeries(snaps);
for (const k of ['apple', 'play'] as const) {
if (series[k].length) continue;
const last = [...snaps].sort((x, y) => x.date.localeCompare(y.date)).reverse().find(s => s[k] && 'error' in s[k]!);
if (last) out[k] = (last[k] as { error: string }).error;
}
return out;
}
export const inWindow = <T extends { date: string }>(rows: T[], start: string, end: string): T[] => rows.filter(r => r.date >= start && r.date <= end);
// ---- compare with listing changes ----

View file

@ -319,4 +319,6 @@ export interface AnalyticsCompare {
play: { date: string; visitors: number; acquisitions: number; installs: number }[];
};
effects: { event: { date: string; commit: string; subject: string; files: string[] }; store: 'apple' | 'play'; before: AnalyticsTotals; after: AnalyticsTotals; daysBefore: number; daysAfter: number }[];
/** Per store with no days in any snapshot: why the newest snapshot has none (no report request yet, no bucket). */
errors?: { apple?: string; play?: string };
}

View file

@ -90,12 +90,14 @@ export function appleSections(md: string): Map<string, Record<string, string | u
return out;
}
function countImages(dir: string): number {
/** Store images of one language: the images in its size folders (<lang>/<size>/...). Files right in the language
* folder (a contact sheet, a preview collage) are not store images and are not counted, like the gallery. */
export function countImages(dir: string, depth = 0): number {
let n = 0;
try {
for (const e of readdirSync(dir, { withFileTypes: true })) {
if (e.isDirectory()) n += countImages(join(dir, e.name));
else if (/\.(png|jpe?g)$/i.test(e.name)) n++;
if (e.isDirectory()) n += countImages(join(dir, e.name), depth + 1);
else if (depth > 0 && /\.(png|jpe?g)$/i.test(e.name)) n++;
}
} catch { /* unreadable: 0 */ }
return n;