Rework the local time tracking system
Create a local array of objects containing all active leitner cards. Each entry will be saved on the server in a new Collection named "leitnerTimeTracking". The collection will only hold the information of cards, which are currently marked as active, the rest will be saved in "leitnerHistory".
[
{
"cardset_id: "6267272",
"card_id": "64536436",
"user_id": "643634634"
"timelineStats": {
"question" {
"active": NUMBER, // Milliseconds
"break": {
"entering": NUMBER // Milliseconds
"active": NUMBER // Milliseconds
"exiting: NUMBER // Milliseconds
}
}
"answer": {
"active": NUMBER, // Milliseconds
"break": {
"entering": NUMBER // Milliseconds
"active": NUMBER // Milliseconds
"exiting: NUMBER // Milliseconds
}
}
}
},
]
Following events will trigger an update on the server:
- Tab / Browser is getting closed
- User skips the active card
- User answered the card
- User is leaving the leitner view
Update the old leitnerHistory documents to use the following new object:
timelineStats: {
question" {
"active": NUMBER, // Milliseconds
"break": {
"entering": NUMBER // Milliseconds
"active": NUMBER // Milliseconds
"exiting: NUMBER // Milliseconds
}
}
"answer": {
"active": NUMBER, // Milliseconds
"break": {
"entering": NUMBER // Milliseconds
"active": NUMBER // Milliseconds
"exiting: NUMBER // Milliseconds
}
},
submitted: DATE
}
Create two timestamps between events and add the difference to the counter.