88 <v-card-title >Summary</v-card-title >
99 <v-list-item >
1010 <v-list-item-content >
11- <v-list-item-title >Best Interval: {{ cardHistory.bestInterval }}</v-list-item-title >
11+ <v-list-item-title
12+ >Best Interval: {{ cardHistory.bestInterval }} seconds ({{ bestIntervalHumanized }})</v-list-item-title
13+ >
1214 <v-list-item-subtitle >The to-date largest interval between successful card reviews.</v-list-item-subtitle >
1315 </v-list-item-content >
1416 </v-list-item >
@@ -38,7 +40,7 @@ import moment, { Moment } from 'moment';
3840interface FormattedRecord extends CardRecord {
3941 formattedTimeStamp: string ;
4042 intervalFromPrevious? : number ;
41- hasNegativeInterval ? : boolean ;
43+ userFriendlyInterval ? : string ;
4244 timeSpentSeconds: number ;
4345}
4446
@@ -66,10 +68,12 @@ export default defineComponent({
6668 return {
6769 history: [] as FormattedRecord [],
6870 cardHistory: null as CardHistory <CardRecord > | null ,
71+ bestIntervalHumanized: ' ' ,
6972 loading: false ,
7073 error: null as string | null ,
7174 headers: [
7275 { title: ' Timestamp' , key: ' formattedTimeStamp' },
76+ { title: ' Interval' , key: ' userFriendlyInterval' },
7377 { title: ' Time Spent (s)' , key: ' timeSpentSeconds' },
7478 { title: ' Correct?' , key: ' isCorrect' },
7579 { title: ' Performance' , key: ' performance' },
@@ -103,6 +107,7 @@ export default defineComponent({
103107 const cardHistoryID = getCardHistoryID (this .courseId , this .cardId );
104108 const historyDoc: CardHistory <CardRecord > = await this .userDB .get (cardHistoryID );
105109 this .cardHistory = historyDoc ;
110+ this .bestIntervalHumanized = moment .duration (historyDoc .bestInterval , ' seconds' ).humanize ();
106111
107112 // Sort records by timestamp and format them
108113 const sortedRecords = [... historyDoc .records ].sort (
@@ -121,6 +126,14 @@ export default defineComponent({
121126 userAnswer: (record as any ).userAnswer ,
122127 };
123128
129+ // Calculate interval from previous record
130+ if (index > 0 ) {
131+ const previousTime = moment (sortedRecords [index - 1 ].timeStamp );
132+ const intervalSeconds = currentTime .diff (previousTime , ' seconds' , true );
133+ formatted .intervalFromPrevious = Math .round (intervalSeconds * 100 ) / 100 ;
134+ formatted .userFriendlyInterval = ` ${formatted .intervalFromPrevious } sec (${moment .duration (intervalSeconds , ' seconds' ).humanize ()}) ` ;
135+ }
136+
124137 return formatted ;
125138 });
126139 } catch (e ) {
0 commit comments