Fix first_rating_count & learn_cost (#2688)
* fix first_rating_count & learn_cost * Update CONTRIBUTORS * cargo clippy --fix * cargo fmt
This commit is contained in:
parent
d2f392ff9f
commit
05499297e0
|
@ -138,7 +138,7 @@ Monty Evans <montyevans@gmail.com>
|
|||
Nil Admirari <https://github.com/nihil-admirari>
|
||||
Michael Winkworth <github.com/SteelColossus>
|
||||
Mateusz Wojewoda <kawa1.11@o2.pl>
|
||||
Jarrett Ye <jarrett.ye@outlook.com>
|
||||
Jarrett Ye <jarrett.ye@outlook.com>
|
||||
Sam Waechter <github.com/swektr>
|
||||
Michael Eliachevitch <m.eliachevitch@posteo.de>
|
||||
|
||||
|
|
|
@ -76,12 +76,15 @@ impl Collection {
|
|||
|
||||
let first_rating_count = revlogs
|
||||
.iter()
|
||||
.filter(|r| {
|
||||
r.review_kind == RevlogReviewKind::Learning
|
||||
&& r.last_interval == 0
|
||||
&& r.button_chosen >= 1
|
||||
.group_by(|r| r.cid)
|
||||
.into_iter()
|
||||
.map(|(_cid, group)| {
|
||||
group
|
||||
.into_iter()
|
||||
.find(|r| r.review_kind == RevlogReviewKind::Learning && r.button_chosen >= 1)
|
||||
})
|
||||
.counts_by(|r| r.button_chosen);
|
||||
.filter(|r| r.is_some())
|
||||
.counts_by(|r| r.unwrap().button_chosen);
|
||||
let total_first = first_rating_count.values().sum::<usize>() as f64;
|
||||
let first_rating_prob = if total_first > 0.0 {
|
||||
let mut arr = [0.0; 4];
|
||||
|
@ -136,11 +139,10 @@ impl Collection {
|
|||
let learn_cost = {
|
||||
let revlogs_filter = revlogs
|
||||
.iter()
|
||||
.filter(|r| r.review_kind == RevlogReviewKind::Learning && r.last_interval == 0)
|
||||
.filter(|r| r.review_kind == RevlogReviewKind::Learning && r.button_chosen >= 1)
|
||||
.map(|r| r.taken_millis);
|
||||
let count = revlogs_filter.clone().count() as f64;
|
||||
if count > 0.0 {
|
||||
revlogs_filter.sum::<u32>() as f64 / count / 1000.0
|
||||
if total_first > 0.0 {
|
||||
revlogs_filter.sum::<u32>() as f64 / total_first / 1000.0
|
||||
} else {
|
||||
return Err(AnkiError::FsrsInsufficientData);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue