-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wordvault] Use recall rate instead of lapses, refactor stats code structure #508
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
661f965
wip
BenMusch 867e546
Merge branch 'benmusch/fix-reorder' into benmusch/recall-rate-display
BenMusch 3fb16e4
Refactor complete
BenMusch 6b824c9
Refactor structure for cleaner diff
BenMusch a1f0be7
final fixes
BenMusch b516dbc
remove unneeded min()
BenMusch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const dateString = (datestr: string, showTime?: boolean) => | ||
`${new Date(datestr).toLocaleDateString()}${ | ||
showTime ? " " + new Date(datestr).toLocaleTimeString() : "" | ||
}`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { dateString } from "../date_string"; | ||
import { CardRecallStat, ParsedFsrsCardStats } from "./types"; | ||
import { Text, TextProps } from "@mantine/core"; | ||
|
||
export interface CardRecallStatsProps { | ||
card: ParsedFsrsCardStats; | ||
showTime?: boolean; | ||
textProps?: Exclude<TextProps, "component">; | ||
valueProps?: Exclude<TextProps, "component">; | ||
excludeStats?: Set<CardRecallStat>; | ||
} | ||
|
||
export function CardRecallStats({ | ||
card, | ||
textProps, | ||
valueProps, | ||
excludeStats = new Set(), | ||
showTime = false, | ||
}: CardRecallStatsProps) { | ||
// The first time a card is incorrectly answered is not logged as a | ||
// lapse, so we exclude that from the calculation of recall rate. | ||
const timesRecalled = card.Reps - 1 - card.Lapses; | ||
|
||
let recallPercentageDisplay: string = "N/A"; | ||
if (card.Reps > 1) { | ||
const recallPercentage = (timesRecalled / (card.Reps - 1)) * 100; | ||
recallPercentageDisplay = | ||
recallPercentage.toLocaleString(undefined, { | ||
minimumFractionDigits: 1, | ||
maximumFractionDigits: 0, | ||
}) + "%"; | ||
} | ||
|
||
return ( | ||
<> | ||
{!excludeStats.has(CardRecallStat.DUE_DATE) && ( | ||
<Text {...textProps}> | ||
Next Due Date:{" "} | ||
<Text component="span" {...valueProps}> | ||
{dateString(card.Due, showTime)} | ||
</Text> | ||
</Text> | ||
)} | ||
{!excludeStats.has(CardRecallStat.LAST_SEEN) && ( | ||
<Text {...textProps}> | ||
Last Seen:{" "} | ||
<Text component="span" {...valueProps}> | ||
{dateString(card.LastReview, showTime)} | ||
</Text> | ||
</Text> | ||
)} | ||
{!excludeStats.has(CardRecallStat.TIMES_SEEN) && ( | ||
<Text {...textProps}> | ||
Times Seen:{" "} | ||
<Text component="span" {...valueProps}> | ||
{card.Reps} | ||
</Text> | ||
</Text> | ||
)} | ||
{!excludeStats.has(CardRecallStat.RECALL_RATE) && ( | ||
<Text {...textProps}> | ||
Recall Rate:{" "} | ||
<Text component="span" {...valueProps}> | ||
{recallPercentageDisplay} | ||
</Text> | ||
</Text> | ||
)} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export type ParsedFsrsCardStats = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if we can get this type def from the back-end codegen, but based on how things were being implement right now I assume not |
||
Difficulty: number; | ||
Due: string; | ||
ElapsedDays: number; | ||
Lapses: number; | ||
LastReview: string; | ||
Reps: number; | ||
ScheduledDays: number; | ||
Stability: number; | ||
State: number; | ||
}; | ||
|
||
export enum CardRecallStat { | ||
DUE_DATE, | ||
TIMES_SEEN, | ||
RECALL_RATE, | ||
LAST_SEEN, | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not entirely true. If you answer it incorrectly after getting it right the very first time you see it, that counts as a lapse. If you answer it incorrectly the first time, and then answer it correctly the second time, you have no lapses. So subtracting 1 always is not quite right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh I see, in that case I don't think we can get to recall % without a back-end change as well, right? probably not worth the effort then relative to other tasks I was gonna take a look at
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I don't think we can get recall % without keeping track of the actual number of times the question has been answered wrong. The best way I can think of getting this is from the log array that gets stored with each question, and just counting the incorrect entries. Or we can cache that number in that JSON blob too. But probably not worth it for right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looping back, how certain are you that this is correct?
I'm pretty certain I have a non-zero number of cards I've never gotten right that show
Times forgotten: {times seen - 1}