-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
feat: Add premium user check in celery task #2668
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will greatly improve latency on chat routes ! 👍🏼
Comments about future optimizations and some logic on the user_settings delete
if subscription["customer"] == customer["id"] | ||
] | ||
logger.debug(f"Matching subscription: {matching_subscription}") | ||
user_id = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be a join on the customer<->user on the email so we can get all at the same time. Not critical for now! maybe just a TODO 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not possible with supabase without a foreign key. Being foreign table I can't do that
.execute() | ||
).data | ||
if len(user_settings) > 0: | ||
supabase_db.table("user_settings").delete().match( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small question here if len(match_subscription) == 0
do we delete the row or update the is_premium
to False ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm deleting the row because then when the user ask a new question it will insert with the models, questions and all by default. Otherwise I have to look for the default value of the db manually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
🤖 I have created a release *beep* *boop* --- ## 0.0.264 (2024-06-13) ## What's Changed * fix: name passed in sync authorize by @StanGirard in #2665 * feat: Add premium user check in celery task by @StanGirard in #2668 **Full Changelog**: v0.0.263...v0.0.264 --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
"This pull request adds a new celery task called
check_if_is_premium_user
that checks if a user is a premium user based on their subscription status. The task retrieves the list of active subscriptions and the list of customers from the Supabase database. It then matches the subscriptions with the customers and updates the user settings with the corresponding premium features if a match is found. If a user is not found or their subscription is expired, the user settings are deleted. This task will run periodically to keep the user settings up to date with the subscription status.