Different amount of reviews on my app vs website?

If anyone is familiar with the WaniKani api (v2) I would greatly appreciate some help.

A while back I created my own iPhone app for WaniKani, and while it wasn’t fully complete, it worked enough that I could use it without issues. It always correctly displayed the amount of reviews I had, whereas another app that I had gotten from the app store would sometimes show more reviews than I actually had.

Well, now my app is showing a different amount of reviews than the website. Currently I have ~230 on the website, but my app only says ~150. And the other day it said I had more reviews than the website.

For some context, I am currently accessing the ‘/summary’ endpoint, and using that to get a list of id’s of the currently available reviews. Then I use this list to download the information associated with each item.

My Mac has been having issues lately so I’m not sure if I can even fix my app at this moment, but I’m just trying to get some understanding on how my app is suddenly not working properly. It doesn’t seem that the api has changed at all.

Any help would be appreciated.

1 Like

Using the summary endpoint is very reliable in my experience, so you seem to be doing things right in that respect.

To address the simplest explanation I can think of… I don’t know where in the world you are, but parts of the world have already switched to DST. Are you sure you are correctly handling the timestamps coming from the API or the timestamps you are sending to the API? The API uses UTC timestamps with an explicit Z timezone suffix, and if you need to convert that to local time in your app you’ll have to use a timezone- and DST-aware method for that. It’s easy to get that almost-but-not-quite right and then get bitten on the next DST change.

If that’s not it, no idea.

Honestly I’m not even considering the timestamps. I’m downloading the summary and using whatever reviews are currently available. I know it has the future reviews for each hour, but if I remember correctly the first array just has all the currently available ones. (Eventually I would want my app to handle the timestamps but I didn’t get that far with it)

Even if daylight savings was an issue, it’s 100 reviews off, and I definitely did not get 100 new reviews at once.

I’m pretty baffled. I’ll have to review my code when I can get my Macbook booted up. Thanks for the suggestion though.

It’s just really weird. I have more lessons now and I can see that those are wrong as well. Actually, the number of lessons/reviews does not change at all. Even if I try to completele one through my app, it doesn’t change the total. The app is downloading the summary as soon as it boots, and it isn’t storing anything between runs of the app.

Now that I had a chance to get my macbook to turn on, I went into xcode and ran this in the simulator. It works perfectly fine. I really wish I could understand what the heck is going on, because if I were going to actually put this on the appstore then it would be pretty important. It is just very bizarre.

With the simulator it’s easy to guarantee that the app starts in a consistent state.

But on the device… all things could happen. App could go to the background, be in the foreground but inactive, be in the foreground and active, get suspended (which is different from background), get detached, get terminated, etc.

Subsequent runs of the app might not be subsequent runs at all – rather the app might have been frozen in the background then got re-activated. If the app didn’t re-load the summary again (or loads the summary again when it shouldn’t), then counts will be wrong.

Ways to test… from XCode with the device tethered, run the app on the device (in debug mode) instead of on the simulator. Dump the content of /summary on boot. Does it always give the correct count after stopping & restarting?

If you use a tool (like Postman) to make API calls, does it always return the correct counts?

Well, since it looks like you’re not doing anything weird with the API, you’d have to share a little bit about the app itself. What does the lifecycle of your app look like? When in the lifecycle of the app do you query the summary? How do you update your app state when a review has been completed in the app (as in, do you just remove the item from the summary, or do you regularly re-fetch the summary, or something else)? As peekay mentioned, app lifecycle is generally a lot more complex than just “it starts when I open the app, and exits when I go back to the home screen”.


Thanks for you guy’s suggestions. I decided to ask about this on the Swift subreddit, since I came to the conclusion that it was probably more related to that rather than WaniKani. I still don’t know exactly why this happened, but it turns out that I was able to change up my code a bit, and set the cachePolicy to reloadIgnoringLocalCacheData.

So yeah, I’m not sure why it was caching the response, or why it randomly did it after months of never once doing this (unless I just never noticed). Honestly having the app cache the response sounds like something I would have to setup manually, I would never have expected it to happen automatically.

Well, anyways, at least I got it sorted out.