mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
parent
f496411da8
commit
880c7d366c
6 changed files with 31 additions and 5 deletions
|
@ -74,9 +74,11 @@ message GraphsResponse {
|
|||
}
|
||||
message Eases {
|
||||
map<uint32, uint32> eases = 1;
|
||||
float average = 2;
|
||||
}
|
||||
message Retrievability {
|
||||
map<uint32, uint32> retrievability = 1;
|
||||
float average = 2;
|
||||
}
|
||||
message FutureDue {
|
||||
map<int32, uint32> future_due = 1;
|
||||
|
|
|
@ -10,20 +10,33 @@ impl GraphsContext {
|
|||
/// (SM-2, FSRS)
|
||||
pub(super) fn eases(&self) -> (Eases, Eases) {
|
||||
let mut eases = Eases::default();
|
||||
let mut card_with_ease_count: usize = 0;
|
||||
let mut difficulty = Eases::default();
|
||||
let mut card_with_difficulty_count: usize = 0;
|
||||
for card in &self.cards {
|
||||
if let Some(state) = card.memory_state {
|
||||
*difficulty
|
||||
.eases
|
||||
.entry(percent_to_bin(state.difficulty() * 100.0))
|
||||
.or_insert_with(Default::default) += 1;
|
||||
difficulty.average += state.difficulty();
|
||||
card_with_difficulty_count += 1;
|
||||
} else if matches!(card.ctype, CardType::Review | CardType::Relearn) {
|
||||
*eases
|
||||
.eases
|
||||
.entry((card.ease_factor / 10) as u32)
|
||||
.or_insert_with(Default::default) += 1;
|
||||
eases.average += card.ease_factor as f32;
|
||||
card_with_ease_count += 1;
|
||||
}
|
||||
}
|
||||
if card_with_ease_count != 0 {
|
||||
eases.average = eases.average / 10.0 / card_with_ease_count as f32;
|
||||
}
|
||||
if card_with_difficulty_count != 0 {
|
||||
difficulty.average = difficulty.average * 100.0 / card_with_difficulty_count as f32;
|
||||
}
|
||||
|
||||
(eases, difficulty)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ impl GraphsContext {
|
|||
/// (SM-2, FSRS)
|
||||
pub(super) fn retrievability(&self) -> Retrievability {
|
||||
let mut retrievability = Retrievability::default();
|
||||
let mut card_with_retrievability_count: usize = 0;
|
||||
let timing = SchedTimingToday {
|
||||
days_elapsed: self.days_elapsed,
|
||||
now: Default::default(),
|
||||
|
@ -28,8 +29,15 @@ impl GraphsContext {
|
|||
.retrievability
|
||||
.entry(percent_to_bin(r * 100.0))
|
||||
.or_insert_with(Default::default) += 1;
|
||||
retrievability.average += r;
|
||||
card_with_retrievability_count += 1;
|
||||
}
|
||||
}
|
||||
if card_with_retrievability_count != 0 {
|
||||
retrievability.average =
|
||||
retrievability.average * 100.0 / card_with_retrievability_count as f32;
|
||||
}
|
||||
|
||||
retrievability
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,10 +17,11 @@ import type { HistogramData } from "./histogram-graph";
|
|||
|
||||
export interface GraphData {
|
||||
eases: Map<number, number>;
|
||||
average: number;
|
||||
}
|
||||
|
||||
export function gatherData(data: GraphsResponse): GraphData {
|
||||
return { eases: numericMap(data.difficulty!.eases) };
|
||||
return { eases: numericMap(data.difficulty!.eases), average: data.difficulty!.average };
|
||||
}
|
||||
|
||||
function makeQuery(start: number, end: number): string {
|
||||
|
@ -101,7 +102,7 @@ export function prepareData(
|
|||
const tableData = [
|
||||
{
|
||||
label: tr.statisticsAverageDifficulty(),
|
||||
value: xTickFormat(sum(Array.from(allEases.entries()).map(([k, v]) => (k + 2.5) * v)) / total),
|
||||
value: xTickFormat(data.average),
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
@ -17,10 +17,11 @@ import type { HistogramData } from "./histogram-graph";
|
|||
|
||||
export interface GraphData {
|
||||
eases: Map<number, number>;
|
||||
average: number;
|
||||
}
|
||||
|
||||
export function gatherData(data: GraphsResponse): GraphData {
|
||||
return { eases: numericMap(data.eases!.eases) };
|
||||
return { eases: numericMap(data.eases!.eases), average: data.eases!.average };
|
||||
}
|
||||
|
||||
function makeQuery(start: number, end: number): string {
|
||||
|
|
|
@ -17,10 +17,11 @@ import type { HistogramData } from "./histogram-graph";
|
|||
|
||||
export interface GraphData {
|
||||
retrievability: Map<number, number>;
|
||||
average: number;
|
||||
}
|
||||
|
||||
export function gatherData(data: GraphsResponse): GraphData {
|
||||
return { retrievability: numericMap(data.retrievability!.retrievability) };
|
||||
return { retrievability: numericMap(data.retrievability!.retrievability), average: data.retrievability!.average };
|
||||
}
|
||||
|
||||
function makeQuery(start: number, end: number): string {
|
||||
|
@ -101,7 +102,7 @@ export function prepareData(
|
|||
const tableData = [
|
||||
{
|
||||
label: tr.statisticsAverageRetrievability(),
|
||||
value: xTickFormat(sum(Array.from(allEases.entries()).map(([k, v]) => (k + 2.5) * v)) / total),
|
||||
value: xTickFormat(data.average),
|
||||
},
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in a new issue