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

Usage Count and Money directly with App Details #1423

Merged
merged 15 commits into from
Dec 3, 2024
Merged

Conversation

mdmohsin7
Copy link
Collaborator

@mdmohsin7 mdmohsin7 commented Nov 27, 2024

ScreenRecording_12-03-2024.13-13-11_1.1.mp4

@mdmohsin7 mdmohsin7 marked this pull request as ready for review November 27, 2024 10:31
@beastoin
Copy link
Collaborator

1/ dont loops infra, pls try to replicate this implementation https://github.com/BasedHardware/omi/pull/1423/files#diff-6a4c2c7ecc69146760e88741b9b4993cf1b06de4ae8da18a98db00601641708bR43 / #1353

2/ resolve conflicts pls sir

@mdmohsin7 feel free to DM @nquang29

@mdmohsin7
Copy link
Collaborator Author

mdmohsin7 commented Nov 28, 2024

1/ Since @nquang29 already implemented it and his PR was merged few hours ago in main, this issue got resolved after I merged main branch in this PR branch
44f192d#diff-6a4c2c7ecc69146760e88741b9b4993cf1b06de4ae8da18a98db00601641708bR108

2/ done

Pls check @beastoin

@beastoin
Copy link
Collaborator

1/ send me the specific line of codes pls. i still see you call the getxyz directly:
Screenshot 2024-11-29 at 08 57 23
2/ ok ✅

@mdmohsin7

@mdmohsin7
Copy link
Collaborator Author

You are referring to get_app_money_made_amount and get_app_usage_count? Those aren't directly coming from redis. The usage is actually stored in firestore. get_app_usage_history fetches the docs from firestore and then caches it in redis for 10 mins. Same with the get_app_money_made

Screenshot 2024-11-29 at 5 30 40 PM

@beastoin

@beastoin
Copy link
Collaborator

beastoin commented Dec 1, 2024

1/ infras - redis, firestore, any database,..., any third-party services, even your disk resource. loops in redis is similar to loops in firestore. that's bad. so let's use the bulk query or the similar technique to remove the loop.
3/ https://github.com/BasedHardware/omi/pull/1423/files#diff-e9334601001806a62e30da99b753c713c2c20213a661ced0a88542e66e39697eR114 do not put the business logic in db layer. why don't you just remove the usage < Nov ?

@mdmohsin7 man

@mdmohsin7
Copy link
Collaborator Author

Alright! Let me fix it. Won't remove the existing loops functions because they were added way back and the analytics endpoints in the app rely on them

@mdmohsin7
Copy link
Collaborator Author

1/ No more looping
2/ Deleted usage history before nov1 on both dev and prod

@beastoin

@beastoin
Copy link
Collaborator

beastoin commented Dec 2, 2024

1/ man... what do you mean "no more looping"
Screenshot 2024-12-02 at 11 54 27

2/ ✅

@mdmohsin7

@mdmohsin7
Copy link
Collaborator Author

1/ because get_app_usage_count_db does not loop anymore. It directly uses the count() function of firestore

Screenshot 2024-12-02 at 10 28 37 AM

@beastoin 😄

@beastoin
Copy link
Collaborator

beastoin commented Dec 2, 2024

1/ loop here man. currently, we have 200+ app, so these line of code would send 200+ requests to infra(redis, firestore), right? that's bad.
Screenshot 2024-12-02 at 12 06 35

@mdmohsin7 ^

@mdmohsin7
Copy link
Collaborator Author

mdmohsin7 commented Dec 2, 2024

Looks like I'll never get this PR approved XD
Let me use mget like @nquang29 did for reviews and try

How would I do it without loops for firebase (multiple apps and only the count)? Let me figure it out

@beastoin
Copy link
Collaborator

beastoin commented Dec 3, 2024

@mdmohsin7 pls follow these instruction to get this ticket done asap:
1/ don't include any heavy aggregations(e.g. money calculation) while getting multiple apps
2/ in the get app detail api route, you could include these metric(money), simply use the get_app_money_made_amount, if we don't have this route yet then create new one e.g. v1/apps/:app_id

pls lmk what you think

@beastoin
Copy link
Collaborator

beastoin commented Dec 3, 2024

lgtm @mdmohsin7 🥳

@beastoin beastoin merged commit 167832f into main Dec 3, 2024
@beastoin beastoin deleted the usage-and-money branch December 3, 2024 08:05
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