Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix undefined error when trying to calculate review stats #5

Merged
merged 3 commits into from Jun 6, 2023

Conversation

sandra-thieme
Copy link
Contributor

This should fix the error reported in wk forum https://community.wanikani.com/t/statkani-data-visualizations-for-wanikani/53929/83:

TypeError: Cannot read properties of undefined (reading ‘mc’)
at dashboard-ca154bcdaa3a0de2bb01.js:1:14203
at Array.reduce ()
at ye (dashboard-ca154bcdaa3a0de2bb01.js:1:14173)
at ro (framework-2191d16384373197bc0a.js:1:60216)
at jo (framework-2191d16384373197bc0a.js:1:69783)
at Hu (framework-2191d16384373197bc0a.js:1:113665)
at Pi (framework-2191d16384373197bc0a.js:1:99848)
at xi (framework-2191d16384373197bc0a.js:1:99776)
at _i (framework-2191d16384373197bc0a.js:1:99639)
at vi (framework-2191d16384373197bc0a.js:1:96605)
uu @ framework-2191d16384373197bc0a.js:1
main-d7431fe8ee9bc358dd07.js:1 TypeError: Cannot read properties of undefined (reading ‘mc’)
at dashboard-ca154bcdaa3a0de2bb01.js:1:14203
at Array.reduce ()
at ye (dashboard-ca154bcdaa3a0de2bb01.js:1:14173)
at ro (framework-2191d16384373197bc0a.js:1:60216)
at jo (framework-2191d16384373197bc0a.js:1:69783)
at Hu (framework-2191d16384373197bc0a.js:1:113665)
at Pi (framework-2191d16384373197bc0a.js:1:99848)
at xi (framework-2191d16384373197bc0a.js:1:99776)
at _i (framework-2191d16384373197bc0a.js:1:99639)
at vi (framework-2191d16384373197bc0a.js:1:96605)
le @ main-d7431fe8ee9bc358dd07.js:1

Tried it locally and it works now. The issue was that there seems to be a new review stat type kana_vocabulary which I've now just added to the initial state for the reduce.

@nanyaDev
Copy link
Owner

nanyaDev commented Jun 6, 2023

Thanks for the PR! 🙇‍♂️

I've noticed the same bug is present in the assignments.reduce(...) statement on line 87 of dashboard.js, which will not be fixed by this PR. That bug is probably not causing issues yet because it will only appear once a kana vocab item has been burned.

Both bugs could be fixed using your approach, but I'm not keen on distinguishing between kana vocab and kanji vocab - I would think that most users would just want a single vocab category. So I've pushed code that fixes both bugs by merging the kana_vocabulary and vocabulary types instead.

Unfortunately, I can't replicate the error or test the fix becauase I haven't used WK since they added the new kana vocabulary, so my personal API data does not return any subject_type: 'kana_vocabulary' items. If you could test that my fix works using the Vercel preview, that would be greatly appreciated! 🙏

@nordihydrocapsaicin
Copy link

Works fine on the Vercel preview.

@nanyaDev nanyaDev merged commit f73b47a into nanyaDev:main Jun 6, 2023
1 check passed
@nanyaDev nanyaDev added the bug Something isn't working label Jun 6, 2023
@sandra-thieme
Copy link
Contributor Author

I've noticed the same bug is present in the assignments.reduce(...) statement on line 87 of dashboard.js, which will not be fixed by this PR. That bug is probably not causing issues yet because it will only appear once a kana vocab item has been burned.

Both bugs could be fixed using your approach, but I'm not keen on distinguishing between kana vocab and kanji vocab - I would think that most users would just want a single vocab category. So I've pushed code that fixes both bugs by merging the kana_vocabulary and vocabulary types instead.

Thanks for looking into this further! 🥳
I'm not familiar enough with the codebase so I didn't notice the other problem. And I've just resetted to the beginning, so I don't have any burned items and wouldn't have noticed it locally or in the preview 😅

@sandra-thieme sandra-thieme deleted the kana-vocabulary-fix branch June 7, 2023 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants