diff --git a/ts/routes/graphs/TrueRetention.svelte b/ts/routes/graphs/TrueRetention.svelte index 37af98116..b9a3f0efc 100644 --- a/ts/routes/graphs/TrueRetention.svelte +++ b/ts/routes/graphs/TrueRetention.svelte @@ -35,6 +35,5 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html .true-retention-table { overflow-x: auto; margin-top: 1rem; - display: flex; } diff --git a/ts/routes/graphs/true-retention.ts b/ts/routes/graphs/true-retention.ts index 8aa5079a8..34160ec10 100644 --- a/ts/routes/graphs/true-retention.ts +++ b/ts/routes/graphs/true-retention.ts @@ -20,69 +20,82 @@ function calculateRetention(passed: number, failed: number): string { return localizedNumber((passed / total) * 100, 1) + "%"; } -function createStatsRow(name: string, data: TrueRetentionData): string { - const youngRetention = calculateRetention(data.youngPassed, data.youngFailed); - const matureRetention = calculateRetention(data.maturePassed, data.matureFailed); - const totalPassed = data.youngPassed + data.maturePassed; - const totalFailed = data.youngFailed + data.matureFailed; - const totalRetention = calculateRetention(totalPassed, totalFailed); +enum Scope { + Young, + Mature, + Total, +} + +function createStatsRow(period: string, data: TrueRetentionData, scope: Scope): string { + let pass: number, fail: number, retention: string; + switch (scope) { + case Scope.Young: + pass = data.youngPassed; + fail = data.youngFailed; + retention = calculateRetention(data.youngPassed, data.youngFailed); + break; + case Scope.Mature: + pass = data.maturePassed; + fail = data.matureFailed; + retention = calculateRetention(data.maturePassed, data.matureFailed); + break; + case Scope.Total: + pass = data.youngPassed + data.maturePassed; + fail = data.youngFailed + data.matureFailed; + retention = calculateRetention(pass, fail); + break; + } return `
${tr.statisticsTrueRetentionRange()} | -${tr.statisticsReviewsTitle()} | +${scopeRange(scope)} | +${tr.statisticsTrueRetentionPass()} | +${tr.statisticsTrueRetentionFail()} | +${tr.statisticsTrueRetentionRetention()} | ||||||||
${tr.statisticsCountsYoungCards()} | -${tr.statisticsCountsMatureCards()} | -${tr.statisticsCountsTotalCards()} | -|||||||||||
${tr.statisticsTrueRetentionPass()} | -${tr.statisticsTrueRetentionFail()} | -${tr.statisticsTrueRetentionRetention()} | -${tr.statisticsTrueRetentionPass()} | -${tr.statisticsTrueRetentionFail()} | -${tr.statisticsTrueRetentionRetention()} | -${tr.statisticsTrueRetentionPass()} | -${tr.statisticsTrueRetentionFail()} | -${tr.statisticsTrueRetentionRetention()} | -