downforacross / downforacross.com

Web frontend for downforacross.com -- continuation of stevenhao/crosswordsio
https://downforacrosscom.downforacross1.now.sh
MIT License
220 stars 92 forks source link

Add stats #275

Closed dlakata closed 1 year ago

dlakata commented 1 year ago

Similar to https://github.com/downforacross/downforacross.com/issues/247, I thought it could be helpful to see the times of one's previous solves. As far as I could tell, the stats modules weren't used, so I repurposed them for this.

Let me know what you think!

crossword_stats
vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
downforacross.com ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 24, 2023 3:02am
dlakata commented 1 year ago

from the preview link above, it seems that the new stats endpoint isn't accessible? it's working locally for me, so I'm not sure what the cause might be

stevenhao commented 1 year ago

Hey thanks for this PR! Love the idea, I'll take a look. The vercel preview is frontend-only, so it makes sense that your server-side changes aren't reflected.

stevenhao commented 1 year ago

At first glance things look good -- maybe can add # players to History? + whether the game is in-progress or solved (and change the link to /replay/gid if it's completed)

dlakata commented 1 year ago

I also was interested in getting the player count! But I was finding that the backend isn't aware of multiple users, where game_events don't actually have a user populated on them. Could you give me some pointers here?

If you'd prefer this, I can definitely rework things to handle incomplete games. My original thinking was that "stats" would only be useful for complete games, and https://downforacross.com/?complete=0&in_progress=1&new=0 could be used to see incomplete games. What do you think?

I updated all the links to the replay link!

stevenhao commented 1 year ago

i checked this out locally and it looks great! i left some small nitpicky comments inline, happy to merge after those are addressed.

as a follow-up after this is merged, i think it'd be a good idea to do a backfill and eagerly store & maintain the stats in the db to avoid having to do expensive queries. this would also allow us to track stats like number of distinct users + anything else we want to include in the stats page (there may be user feedback that we can act on).

dlakata commented 1 year ago

I think I made all your suggested changes! and added another log line to help measure the performance of the endpoint. another index that might be good would be on puzzle_solves prefixed with gid rather than pid

idk what your database maintenance looks like, but yeah would be happy to help. when marking a puzzle solve, we could probably record the revealed/checked count. I wonder what stats other users would want (filtering different conditions, per time period, longest/current streak, day-of-week stats), and user feedback + performance could tell us what to improve

stevenhao commented 1 year ago

great, thanks! merging this, i'll try to keep an eye on performance but not overly worried for now since there's limits on how many games are considered at once for stats