[Userscript] Wanikani Heatmap

so what did you do to fix it?

Refreshing wof.file_cache doesn’t fix it for me unfortunately

It just worked when I tried it again on a different day…

With ā€˜reviews’, it can also be the rate-limit on the server, which might make it pause for a minute (60 seconds) before resuming again. But if it doesn’t, refreshing the cache file is the usual fix, as others have said.

2 Likes

yeah refresh, that didn’t work, but I am getting this:
image

Hmm, that’s ā€œservice unavailableā€. Could be a temporary glitch in the matrix. But if it persists, I’d ask Tofugu.

Side comment: I noticed that my own WK account stopped working on my own wkstats site due to certain WK API queries taking too long. I haven’t reported it because I’m done with my WK journey and didn’t figure it was a priority. (Plus I know that timed-out queries show up in a report, so they’ll see it eventually, which is soon enough for my purposes)

2 Likes

Little frustrating because under Chrome it works. - Maybe I will just switch to one and only google for heatmap. :-/

I’m in the opposite situation, it’s not working for me on chrome so I might have to switch to a different browser for the script until it eventually stops working there too.

So… I’ve noticed that on my dashboard the time it takes for the heatmap to load is mostly governed by the Apiv2 retrieval of the reviews via the review cache, which it does with a filter with updated_after.

I’ve locally tweaked it by first checking against the datetime of the last review session. I’m assuming here that there is no point in trying to fetch reviews if they’ve been fetched since the last review session already, regardless of how long ago that was. I think offline reviews on a phone app will also be visible on the review overview page once they are sync’ed.

        // Modified to only check for new reviews if a review session occurred in the mean time
        async function update_data_after_session(data) {
            if (!data.cache_version || data.cache_version < cache_version) data = {cache_version, date: "1970-01-01T00:00:00.000Z", reviews: [],}

            // insert extra check
            var lastReviewSessionDate = wkof.load_file('/review').then(parse_last_review_session, fail_last_review_session);
            if (lastReviewSessionDate) {
                if (new Date(lastReviewSessionDate).getTime() < new Date(data.date).getTime()) {
                    // no new review sessions since last fetch, simply returned cached data
                    return data.reviews;
                }
            }
            // else fetch new
            // end insert extra check

            let [date, new_reviews] = await fetch_new_reviews(data.date);
            if (new_reviews.length) {
                for (let new_review of new_reviews) data.reviews.push(new_review);
                data.reviews.sort((a,b) => a[0]<b[0] ? -1 : 1);
                data.date = date;
                save(data);
            }
            return data.reviews;

            //====================
            function parse_last_review_session(html) {
                return $(html).find('#last-session-date time')[0].getAttribute('datetime');
            }
            function fail_last_review_session(reason) {
                console.log("failed to check last review session date: " + reason);
                return null;
            }
        }

Locally this speeds up the loading of the heatmap considerably (provided I’ve not run review sessions that is). Wondering if you think this is a good idea to include.

8 Likes

Not Kumirei, but I like this idea

1 Like

Not not Kumirei, but this is a great idea!

4 Likes

Not not Kumirei enough

1 Like

1 Like

Hey, absolutely love the script!

Here’s a little bug that’s been bothering me for a while though:

The info spills out and can often be unreadable

2 Likes

Oh, that’s not right! Will look into it when I get the time

2 Likes

Quick question out of interest: does the heatmap fetch all your reviews on each page refresh? If so, why doesn’t it only fetch new reviews since the last fetch, wouldn’t that massively speed it up? Sorry if I’m missing something obvious, I’m just curious about it :sweat_smile:

1 Like

The heatmap caches your old reviews :wink:

1 Like

It does cache your reviews, however, the issue is that in the last few months WK has had extremely slow response times on the reviews API, so just fetching the new reviews takes a very long time. @rwesterhof has provided an update to the script which will at least make it faster when there are no new reviews, but I haven’t found the time to merge it yet. Hopefully in a few days

3 Likes

Hello, currently I also have the problem of my reviews not fully loading. I did my reviews on my phone for a while, so I have a lot of new reviews to load, but the last request stays at pending and after about a minute changes to 503 with some errors in the console.
image
image
Last time this problem was mentioned here it seems that it went away after a few days, but I wanted to ask if there a some things I could try to fix this. I have cleared the cache, restarted the computer, have only used Open Framework and Heatmap, Open Framework being before Heatmap and i dont have any adblockers installed.

1 Like

I’m sorry, I have no idea why this is happening. It is very strange that the previous request go through but that one is blocked by CORS. Also it shouldn’t thake that long for the request. Perhaps the CORS issue is related to the long response times we’ve been seeing on the reviews endpoint. @Mods do you know if the engineering team has looked into this yet? @skatefriday said they sent you an email in February

2 Likes