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(publish-quota): per user publishArticle quota #3862

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

tx0c
Copy link
Contributor

@tx0c tx0c commented Apr 16, 2024

resolves #3842

@tx0c tx0c self-assigned this Apr 16, 2024
@tx0c tx0c requested a review from a team as a code owner April 16, 2024 20:19
gary02
gary02 previously requested changes Apr 18, 2024
@@ -50,6 +57,21 @@ const resolver: GQLMutationResolvers['publishArticle'] = async (
throw new UserInputError('content is required')
}

const fieldName = 'publishArticle'
const pass = await checkOperationLimit({
user: viewer.id || viewer.ip,
Copy link
Contributor

Choose a reason for hiding this comment

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

viewer.ip will never be used as only logged-in user can publish articles by now?

Copy link
Contributor

Choose a reason for hiding this comment

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

And as opercation limit is checked here, rateLimitDirective (@ratelimit) on publishArticle in schema need to be removed

@@ -16,3 +18,6 @@ export const AUTHOR_TYPE = {
default: 'default',
trendy: 'trendy',
} as const

export const PUBLISH_ARTICLE_RATE_LIMIT = isProd ? 1 : 1000
Copy link
Contributor

Choose a reason for hiding this comment

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

is this rate confirmed with the CC team?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it was the default before:

"hotfix(publish-rate): reduce rate of publishArticle"

This reverts commit 2717c88.

})

if (!pass) {
throw new ActionLimitExceededError(
Copy link
Contributor

@robertu7 robertu7 Apr 22, 2024

Choose a reason for hiding this comment

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

add unit test for this mutation changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added in src/types/__test__/1/article.test.ts

Copy link

codecov bot commented May 28, 2024

Codecov Report

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

Project coverage is 58.59%. Comparing base (a4040ba) to head (09410fe).
Report is 1 commits behind head on develop.

Files Patch % Lines
src/mutations/user/updateUserPublishRate.ts 41.66% 7 Missing ⚠️
src/common/utils/rateLimit.ts 75.00% 6 Missing ⚠️
...ions/20240531164251_alter_user_add_publish_rate.js 71.42% 2 Missing ⚠️
src/mutations/article/publishArticle.ts 88.88% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3862      +/-   ##
===========================================
+ Coverage    58.57%   58.59%   +0.01%     
===========================================
  Files          887      890       +3     
  Lines        17184    17216      +32     
  Branches      3089     3095       +6     
===========================================
+ Hits         10065    10087      +22     
- Misses        7068     7078      +10     
  Partials        51       51              

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

@tx0c tx0c force-pushed the feat/publish-quota branch 2 times, most recently from fd27c9b to c444559 Compare May 29, 2024 22:56
@tx0c
Copy link
Contributor Author

tx0c commented May 29, 2024

how about Revert "hotfix(publish-rate): reduce rate of publishArticle"

This reverts commit 2717c88.

Let the graphql directive still handles a 10articles/2hours bottom limit?

@gary02 gary02 dismissed their stale review September 5, 2024 07:30

need to review

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.

per user publishArticle quota
3 participants