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

Use firebase aggregate functions to get stats #54

Closed
wants to merge 2 commits into from

Conversation

technophile-04
Copy link
Member

@technophile-04 technophile-04 commented Mar 1, 2024

Description

Please feel free to close this !!

Used firebase aggregation queries for reading stats.

Instead of reading all documentation and their fields, Since for stats we just need their counts and Firebase also provides aggregation to get the sum of sum field values. This might save us a bit on pricing

Had to upgrade from firebase-admin to v12 due to firebase/firebase-admin-node#2374

Also verified v12 now works fine with emulator


Also, we need to index askAmount on firebase :

An authenticated BG Admin to firebase can go to this link and enable indexing for askAmount by just clicking to save :

Popup dialog:

Screenshot 2024-03-01 at 9 42 58 PM

This is should solve vercel deployment issue 🙌

Copy link

vercel bot commented Mar 1, 2024

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

Name Status Preview Updated (UTC)
grants-bg ❌ Failed (Inspect) Mar 1, 2024 4:22pm

@technophile-04
Copy link
Member Author

technophile-04 commented Mar 1, 2024

We need to index askAmount and completedAt and this should work properly 🙌, but lol closed it seems like premature optimization

@carletex
Copy link
Contributor

carletex commented Mar 1, 2024

Thanks for looking into this Shiv! We can take another look when we finish the other stuff.

Instead of reading all documentation and their fields, Since for stats we just need their counts and Firebase also provides aggregation to get the sum of sum field values. This might save us a bit on pricing

One thing that is going to help us optimizing, is using cache. I'm a bit lost on how cache works on NextJS 14 with App router (I think it was way simpler in page router and old nextjs versions).

For example, the landing page, could be cached for hours (in old NextJS I'd have used ISR so it's static generated for X hours).

The only page that needs to be more "alive" is the admin page. And not sure what NextJS does by default. In local dev it's never cached, so it's hard to notice :D A few resources we can look at:

https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating
https://nextjs.org/docs/app/building-your-application/caching
https://www.youtube.com/watch?v=VBlSe8tvg4U&list=WL&index=19&t=853s

Maybe we can create an issue for discussing this

@technophile-04 technophile-04 mentioned this pull request Mar 3, 2024
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