I want to build a simple e-commerce application that lets users buy different digital products. I also want to track every user's total purchase value and get their percentage as a top buyer (Basically ranking based on total money spent).
So a user who spent a total of $50k would have a lower percentage as a top buyer than someone who spent a total of $100.
This is just like OnlyFans, how creators can showcase their percentage as top creators.
Question: How would I derive and store this data in Cloud Firestore, I can easily get the total amount spent by a user but to get their percentage is a bit tricky.
My Opinion: I could simply create a cron job that runs every week or month and would calculate and update every user's rank but I feel that would be expensive if the app scales and cloud Firestore's transactions are limited to 500 writes.