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

feat: check quota correctly #6561

Merged
merged 1 commit into from
Apr 16, 2024
Merged

Conversation

darkskygit
Copy link
Member

No description provided.

Copy link

graphite-app bot commented Apr 15, 2024

Your org has enabled the Graphite merge queue for merging into canary

Add the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @darkskygit and the rest of your teammates on Graphite Graphite

@github-actions github-actions bot added app:server test Related to test cases labels Apr 15, 2024
Copy link

nx-cloud bot commented Apr 15, 2024

@darkskygit darkskygit changed the title feat: migrate quota correctly feat: check quota correctly Apr 15, 2024
Copy link

codecov bot commented Apr 15, 2024

Codecov Report

Attention: Patch coverage is 48.11715% with 124 lines in your changes are missing coverage. Please review.

Project coverage is 61.66%. Comparing base (0ca8a23) to head (1b0864e).

Files Patch % Lines
packages/backend/server/src/core/quota/service.ts 13.04% 40 Missing ⚠️
...ages/backend/server/src/plugins/copilot/session.ts 24.44% 34 Missing ⚠️
...ckages/backend/server/src/core/features/service.ts 25.71% 25 Missing and 1 partial ⚠️
...s/backend/server/src/plugins/copilot/controller.ts 0.00% 8 Missing ⚠️
...ckages/backend/server/src/core/features/feature.ts 53.84% 6 Missing ⚠️
...ages/backend/server/src/plugins/payment/service.ts 0.00% 4 Missing ⚠️
...ges/backend/server/src/core/features/management.ts 50.00% 2 Missing ⚠️
...ges/backend/server/src/plugins/copilot/resolver.ts 60.00% 2 Missing ⚠️
packages/backend/server/src/core/user/resolver.ts 0.00% 1 Missing ⚠️
...s/backend/server/src/core/workspaces/management.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           canary    #6561      +/-   ##
==========================================
- Coverage   61.79%   61.66%   -0.13%     
==========================================
  Files         527      528       +1     
  Lines       25880    26047     +167     
  Branches     2316     2320       +4     
==========================================
+ Hits        15993    16063      +70     
- Misses       9612     9709      +97     
  Partials      275      275              
Flag Coverage Δ
server-test 71.21% <48.11%> (-0.28%) ⬇️
unittest 39.42% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@EYHN EYHN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You use copilot feature here to represent that the user has unlimited copilot permissions. I have a few questions.

  • I don’t seem to see you giving users copilot feature in user subscription and unsubscription.
  • We seem to have used copilot feature to refer to the access rights of the workspace's AI Poc. Is there some confusion?
  • Such changes seem to result in us having two quota systems ( user.copilot.quota and user.quota ). I think we can reuse the previous quota service.

can we implement the quota as "free_ai_plan" and "paied_ai_plan",

When querying quota, merge ai plan with cloud plan:

{
  ...paied_ai_plan,
  ...pro_plan
}

@darkskygit
Copy link
Member Author

You use copilot feature here to represent that the user has unlimited copilot permissions. I have a few questions.

  • I don’t seem to see you giving users feature in user subscription and unsubscription.copilot
  • We seem to have used feature to refer to the access rights of the workspace's AI Poc. Is there some confusion?copilot
  • Such changes seem to result in us having two quota systems ( and ). I think we can reuse the previous quota service.user.copilot.quota``user.quota

can we implement the quota as "free_ai_plan" and "paied_ai_plan",

When querying quota, merge ai plan with cloud plan:

{
  ...paied_ai_plan,
  ...pro_plan
}

The feature was originally designed to declare that "a user has a copilot feature", but it was temporarily used as an aipoc declaration.

Because there was no serverConfig api before, the frontend could not know whether the server module was enabled (for example, in self hosted, captcha will be disable), so the availableFeature was added as an auxiliary judgment. When the frontend can rely on the server and other module activation status send requests, this api should be removed

Copy link
Member

EYHN commented Apr 15, 2024

According to the previous code, copilot feature is linked to workspace, not user

@darkskygit
Copy link
Member Author

According to the previous code, copilot feature is linked to workspace, not user

This can indeed cause confusion, already define a new feature

Copy link
Member

EYHN commented Apr 15, 2024

One last thing, you should give the user the feature when the subscription is activated.

https://github.com/toeverything/AFFiNE/blob/canary/packages/backend/server/src/core/quota/service.ts#L163

@darkskygit
Copy link
Member Author

One last thing, you should give the user the feature when the subscription is activated.

https://github.com/toeverything/AFFiNE/blob/canary/packages/backend/server/src/core/quota/service.ts#L163

fixed

@darkskygit darkskygit requested a review from EYHN April 15, 2024 10:44
Copy link

graphite-app bot commented Apr 16, 2024

Merge activity

@forehalo forehalo force-pushed the darksky/split-copilot-quota branch from 2b6df81 to 1b0864e Compare April 16, 2024 09:42
@graphite-app graphite-app bot merged commit 1b0864e into canary Apr 16, 2024
38 of 40 checks passed
@graphite-app graphite-app bot deleted the darksky/split-copilot-quota branch April 16, 2024 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app:core app:server test Related to test cases
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants