[Userscript] Wanikani Heatmap

Hello, same problem here

3 Likes

@mrahhal and @alihmd

Could you either send your API V2 key to me at kumi@kumirei.com (I wouldnā€™t need write access so if you want to generate a new one without it thatā€™s cool) and/or put this localStorage.getItem('WKheatmapData1.7.0'); in your console and post here or email me the output? Since this is not happening to me I donā€™t really know what the issue could be.

1 Like

This is pretty cool! Iā€™ve been a crabigator since May 2016 so it doesnā€™t all show but I like how I can see where I got burnt out in 2017 with 1000ā€™s of leeches and just quit. I came back 9 months later, reset to level 1 and am just now almost back at my previous level - but feeling much stronger this time around! Almost no leeches and usually only around 100 - 150 reviews a day. (I average 11 days per level)

1 Like

That one lonely day in February 2018

5 Likes

Haha I just noticed that too! I think I opened a browser and did a couple of reviews but I wasnā€™t feeling it so I closed it out again.

1 Like

You seem pretty consistent when youā€™re actually on the horse; thatā€™s nice

1 Like

I ended up sending you 2 emails, one with my token and another with the result. (Discourse didnā€™t allow me to post the result here)

Looking at the result, there was no data at all after 2019 April 1st, thatā€™s weird. Iā€™m guessing the token will help you more in finding whatā€™s going on. All yours, thanks a lot!

1 Like

Done, thanks!

1 Like

@alihmd and @mrahhal Thank you for emailing me.
@mrahhal I only got your key, but I got both from @alihmd so thatā€™s ok.

@alihmd The JSON you sent looks fine, and the data is being stored as it should. Even using your API-key I canā€™t replicate the issue.
image

@mrahhal Same with your API-key
image

Looking at the JSON I see that itā€™s when DST started. However I donā€™t see any issue with the logic that uses the date to produce a timestamp for the heatmap (as I wouldnā€™t since it works for me).

I usually only test on Chrome; what browser are you two using?

2 Likes

I only use it on Chrome.

itā€™s when DST started

Thatā€™s the very first thought Iā€™ve had too actually. What makes this weirder is that I and @alihmd actually live in the same area. Iā€™m not sure whatā€™s up with that. I canā€™t think of any other reason than DST, but youā€™re saying you double checked the logic there and it already works for you.

Maybe itā€™s kinda related to our clock on our machines? If you want, you could tell me what function to call from your script, and Iā€™ll try it out standalone on my machine to see if the results are being returned correctly.

Since the data is present thereā€™s really only one function I can see being the culprit, unless itā€™s an issue with the library creating the elements for the heatmap.

Itā€™s this one, that converts the stored data to the format that the library wants.

		// Transforms the data into the format the heatmaps needs
		function days_to_timestamps(data) {
				var heatmap_data = {};
				for (var day in data) heatmap_data[Date.parse(data[day].date)/1000] = data[day].count;
				return heatmap_data;
		}

Basically it goes through all the days youā€™ve studied, converts the ISO date Iā€™ve stored in there to a unix timestamp in seconds, stores that in heatmap_data along with the number of reviews you did.

I see no reason for this to work for Mar 31 (ex 2019-03-31T10:00:00.000Z) but not Apr 1 (ex 2019-04-01T09:00:00.000Z) and onwards, as Date.parse("2019-04-01T09:00:00.000Z")/1000 would produce a correct unix timestamp.

Most likely Iā€™m just overlooking something, but I have no idea what it might be. If you want to try and see if this is the problem then I suppose you could try

console.log(Date.parse("2019-03-31T10:00:00.000Z"))
console.log(Date.parse("2019-04-01T09:00:00.000Z"))

And see if thereā€™s something wrong with the second output.

1 Like

Iā€™ll do some debugging on it later today, Iā€™ll let you know what happens. Thanks.

1 Like

Ehā€¦ Thatā€™s what I thought, the heatmap data is being produced correctly, but it seems like itā€™s a problem with the heatmap lib, check those issues out:

Seems to me that DST related issues have not been resolved in the repo too. Ouch.

1 Like

Doesnā€™t look like itā€™s going to get resolved either. What timezone are you in?

Yeah.

My timezoneā€™s standard name is ā€œMiddle East Standard Timeā€. Currently UTC+03:00 (DST active).

Now this renders the whole thing unusable. And the issue has been active since 2013, doesnā€™t look like itā€™ll be resolved anytime soon. But I love your extension so much that Iā€™m considering forking that lib just to solve this :sweat_smile:

I wonder if it can be solved by just putting the data on a different hour of the day. Maybe if you try adding an hour or two to the heatmap data through the function I mentioned earlier?

Tried a couple of things, I donā€™t know whatā€™s going on anymore.
Tried replacing all DST dates with a consistent offset, same problem occurred. The data still looks good, problem is definitely somewhere in the lib. Double checked the timestamps too, they all look good. I dunno.

Hm. I figured that since it seems to work for most of us it might be possible for me to patch it by just offsetting, as the time of day the data is on doesnā€™t matter much.

1 Like

With @MissMisc recent achievement of burning all wanikani review items, can we maybe add a special colour/icon/symbol for this?

1 Like

You mean the last day of review (when the last item is burned) should have a different colour?