mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-10 16:19:24 -07:00
fix(stats): address CodeRabbit review on PR #50
- Guard episode deletion against double-submit with an isDeletingRef + setIsDeleting pair threaded through buildDeleteEpisodeHandler, and disable the MediaHeader delete button while a request is in flight. - Restore MediaHeader title truncation by adding min-w-0 flex-1 to the h2 so long titles shrink instead of pushing the delete button away. - Normalize the headword in FrequencyRankTable before comparing it to the (hiragana-normalized) reading so katakana-only entries like カレー no longer render a redundant 【かれー】. Test strengthened to reject any bracketed reading, not just the literal. - Rewrite confirmBucketDelete copy to include the "and all associated data" warning and handle singular/plural cleanly. - Run Prettier across the stats files CI was complaining about (EpisodeDetail, WatchTimeChart, SessionsTab + test, FrequencyRankTable + test, session-grouping test) to clear the format:check:stats gate.
This commit is contained in:
@@ -32,8 +32,20 @@ test('empty input returns empty array', () => {
|
||||
|
||||
test('two unique videoIds produce 2 singleton buckets', () => {
|
||||
const sessions = [
|
||||
makeSession({ sessionId: 1, videoId: 10, startedAtMs: 1000, activeWatchedMs: 100, cardsMined: 2 }),
|
||||
makeSession({ sessionId: 2, videoId: 20, startedAtMs: 2000, activeWatchedMs: 200, cardsMined: 3 }),
|
||||
makeSession({
|
||||
sessionId: 1,
|
||||
videoId: 10,
|
||||
startedAtMs: 1000,
|
||||
activeWatchedMs: 100,
|
||||
cardsMined: 2,
|
||||
}),
|
||||
makeSession({
|
||||
sessionId: 2,
|
||||
videoId: 20,
|
||||
startedAtMs: 2000,
|
||||
activeWatchedMs: 200,
|
||||
cardsMined: 3,
|
||||
}),
|
||||
];
|
||||
const buckets = groupSessionsByVideo(sessions);
|
||||
assert.equal(buckets.length, 2);
|
||||
@@ -45,8 +57,20 @@ test('two unique videoIds produce 2 singleton buckets', () => {
|
||||
});
|
||||
|
||||
test('two sessions sharing a videoId collapse into 1 bucket with summed totals and most-recent representative', () => {
|
||||
const older = makeSession({ sessionId: 1, videoId: 42, startedAtMs: 1000, activeWatchedMs: 300, cardsMined: 5 });
|
||||
const newer = makeSession({ sessionId: 2, videoId: 42, startedAtMs: 9000, activeWatchedMs: 500, cardsMined: 7 });
|
||||
const older = makeSession({
|
||||
sessionId: 1,
|
||||
videoId: 42,
|
||||
startedAtMs: 1000,
|
||||
activeWatchedMs: 300,
|
||||
cardsMined: 5,
|
||||
});
|
||||
const newer = makeSession({
|
||||
sessionId: 2,
|
||||
videoId: 42,
|
||||
startedAtMs: 9000,
|
||||
activeWatchedMs: 500,
|
||||
cardsMined: 7,
|
||||
});
|
||||
const buckets = groupSessionsByVideo([older, newer]);
|
||||
assert.equal(buckets.length, 1);
|
||||
const [bucket] = buckets;
|
||||
|
||||
Reference in New Issue
Block a user