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

Plotly #341

Merged
merged 20 commits into from
Jul 31, 2024
Merged

Plotly #341

merged 20 commits into from
Jul 31, 2024

Conversation

rissois
Copy link
Collaborator

@rissois rissois commented Jul 1, 2024

Dashboard for analyzing user voting behavior

@rissois
Copy link
Collaborator Author

rissois commented Jul 2, 2024

Some notes:

  • Pearsons... I'm like 60% sure it's correct?
  • The legend width tends to jump around, want to find a way to avoid this or we can more the legend to the bottom maybe
  • We need to look into how to remove a user's votes, and if we want that to be a permanent / timed ban.

Copy link
Owner

@heshammourad heshammourad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't run the code, but here are my initial thoughts. Nothing too major, we could probably merge and address the comments later.

react-ui/src/components/AccountMenu.jsx Outdated Show resolved Hide resolved
react-ui/src/components/AccountMenu.jsx Outdated Show resolved Hide resolved
react-ui/src/pages/analyzeVotes/AnalyzeVotes.jsx Outdated Show resolved Hide resolved
react-ui/src/pages/analyzeVotes/AnalyzeVotes.jsx Outdated Show resolved Hide resolved
react-ui/src/pages/analyzeVotes/AnalyzeVotes.jsx Outdated Show resolved Hide resolved
react-ui/src/pages/analyzeVotes/PearsonsCorrelation.jsx Outdated Show resolved Hide resolved
react-ui/src/pages/analyzeVotes/PearsonsCorrelation.jsx Outdated Show resolved Hide resolved
react-ui/src/pages/analyzeVotes/functions.jsx Show resolved Hide resolved
react-ui/src/pages/index.js Outdated Show resolved Hide resolved
server/api/analyzeVotes.js Outdated Show resolved Hide resolved
@rissois
Copy link
Collaborator Author

rissois commented Jul 29, 2024

Applied most of the edits. Three things to note:

  1. Please check this comment on the server return value
  2. I still need to add comments
  3. I got an Uncaught TypeError: user2Points[entryPositionLookup[vote.entryId]] is undefined that I need to chase up.

@heshammourad
Copy link
Owner

Applied most of the edits. Three things to note:

1. Please check [this comment](https://github.com/heshammourad/vexillology-contests/pull/341#discussion_r1694646592) on the server return value

2. I still need to add comments

3. I got an `Uncaught TypeError: user2Points[entryPositionLookup[vote.entryId]] is undefined` that I need to chase up.

Responded to 1. I'll keep an eye on updates for the other 2, but I think if the 3rd issue isn't breaking anything, we can merge and deploy before the next contest starts. Let's see what's done by the 31st.

@rissois
Copy link
Collaborator Author

rissois commented Jul 29, 2024

Ok, I added some comments which hopefully cleared things up. I did not get into the step-by-step of the math, just explained the equations and what each block of code was doing.

Yet another sporadic TypeError came up. Neither one I can reliably reproduce so I'm not sure if this is an artifact of the dev environment, but the two that have come up so far:

  • zScoresByUser[ua.username] (generally the United Mediterranean Sea contest sep23)
  • user2Points[entryPositionLookup[vote.entryId]] (happened at least once for Dungeons and Dragons mar23 contest 11vfqjf)

Sometimes I am getting a 404 for a GET .../api/mod/analyzeVotes/undefined, wondering if this is responsible?

@rissois
Copy link
Collaborator Author

rissois commented Jul 29, 2024

Theory: contestId is undefined. useSwrModAnalyze returns no data, so votes, userAvg, entryAvg, and userEntries are now empty arrays. BUT memoized values like entryPositionLookup are preserved.

If GET .../undefined underlies all the TypeErrors, then we'll probably need to address things at that top level rather than within the individual components. Unless we want to if (!contestId) return null

@heshammourad
Copy link
Owner

heshammourad commented Jul 29, 2024

Theory: contestId is undefined. useSwrModAnalyze returns no data, so votes, userAvg, entryAvg, and userEntries are now empty arrays. BUT memoized values like entryPositionLookup are preserved.

If GET .../undefined underlies all the TypeErrors, then we'll probably need to address things at that top level rather than within the individual components. Unless we want to if (!contestId) return null

Is it possible to have useSwrModAnalyze not make the call when it's passed undefined? Something like https://swr.vercel.app/docs/conditional-fetching#conditional

Edit: On second thought, looks like this wouldn't solve the issue of the memoized values that you mentioned. I think short-circuiting when !contestId sounds like a good fix.

@rissois
Copy link
Collaborator Author

rissois commented Jul 30, 2024

Edit: On second thought, looks like this wouldn't solve the issue of the memoized values that you mentioned. I think short-circuiting when !contestId sounds like a good fix.

Actually undefined is already meant to return the most recent contest.

Based on how this error is not reproducible, it's possible the root cause it a fast refresh/hot reload in dev. I think we should check it out in staging / production, and re-investigate if it still happens live.

@heshammourad heshammourad merged commit aecc235 into heshammourad:master Jul 31, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants