Skip to content

Reduce some firebase reads on homepage for logged-in users - #590

Merged
mdirolf merged 1 commit into
crosshare-org:masterfrom
ianfhunter:reduce_reads
Sep 17, 2026
Merged

mdirolf merged 1 commit into
crosshare-org:masterfrom
ianfhunter:reduce_reads

Conversation

@ianfhunter

Copy link
Copy Markdown
Contributor

After mentioning that firebase reads were one of the costly things about hosting, I had a look around for any quick wins, particularly on the homepage.

This is a change for logged-in users only:

Currently, if a user has not played a puzzle on the homepage (the usual case, I'd imagine), it will either:

  • return undefined. It doesn't know whether the user has played the puzzle. So it will go request the status.
  • return a cached play object. Uses that.
  • return null. This is practially a negative cache - i.e. We know the player has not played the puzzle.

However, the third state is incorrectly grouped with the first, and so it goes and requests the status. And then the read is empty (as it had warned).

This PR changes the third state so that we accept the null state and don't go and request the play data, because we know it wont be there.


Although this is a tiny change, it is not straightforward, so I'd appreciate a double-check of my logic.

@mdirolf

mdirolf commented Sep 17, 2026

Copy link
Copy Markdown
Member

Great catch! Thank you!

@mdirolf
mdirolf merged commit 950eb9e into crosshare-org:master Sep 17, 2026
1 check 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