I am actually planning to add this feature for reviews to the heatmap script, and I have the function to calculate it made already. Mind, though, that it doesn’t count any time before August 4 2017, since WK didn’t store review data before then.
REQUIRES WANIKANI OPEN FRAMEWORK
Ok, so what you want to do is first cache the reviews and define our functions with this. Open up the console and paste it into there.
function get_longest_session(longest_pause) {
var reviews = JSON.parse(localStorage.getItem('review_cache'));
if (!reviews) cache_reviews().then(()=>{time_reviewed(longest_pause)});
else time_reviewed(longest_pause);
}
function cache_reviews() {
return wkof.Apiv2.fetch_endpoint('reviews').then((review_data)=>{
var dates = [];
for (var i=0; i<review_data.data.length; i++) {
var item = review_data.data[i].data;
dates.push(Date.parse(item.created_at));
}
localStorage.setItem('review_cache', JSON.stringify(dates));
});
}
function time_reviewed(longest_pause) {
var reviews = JSON.parse(localStorage.getItem('review_cache'));
var session_start = reviews[0];
var last = session_start;
var time = 0;
var sessions = 1;
for (var i=1; i<reviews.length; i++) {
if ((reviews[i]-last)/1000/60 > longest_pause) {
session_start = reviews[i];
sessions++;
}
else time += reviews[i]-last;
last = reviews[i];
}
console.log('Time reviewed:', (time/1000/60/60).toFixed(2) + 'h');
console.log('Number of sessions:', sessions);
}
Then you can use the command time_reviewed(longest_pause), where longest_pause is replaced with the longest pause (in minutes) between answers allowed. Anything longer than longest_pause will not count towards the total time reviewed.
You will be returned a number of hours and the number of sessions your choice of longest_pause results in. If the latter seems high, you might want to calibrate the former. How you interpret these is up to you.
