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

Implement "getRemainingQuota" auxiliary method to calculate the remaining quota of resources #597

Open
1 task done
MilenaFRocha opened this issue Feb 8, 2025 · 0 comments
Labels
type: feature-request New feature or request

Comments

@MilenaFRocha
Copy link

🔖 Feature description

This feature consists of implementing the "getRemainingQuota" auxiliary method in the PermissionsService class, which aims to calculate the remaining quota of resources available to an organization, based on the settings of its subscription plan. The method evaluates different sections – such as channels (CHANNEL), webhooks (WEBHOOKS) and monthly posts (POSTS_PER_MONTH) – and returns the available balance for each resource, using information from integration services, webhooks, posts and subscriptions. This functionality will assist both in displaying usage information to the user and in validating permissions to use contracted resources.

🎤 Why is this feature needed ?

This feature is necessary to allow the system to monitor, in an accurate and isolated manner, the organizations' resource consumption according to the limits stipulated in their subscription plans. With the "getRemainingQuota" method, it is possible to determine how many channels, webhooks or monthly posts can still be used, ensuring usage control and preventing the organization from exceeding what was contracted.
Usage examples:

  • If an organization's plan allows for 10 integrations and they already have 7 registered, the method will return 3, allowing the system to display how many channels can still be added.
  • For webhooks, when identifying that 8 webhooks were created out of a limit of 10, the method makes it possible to block the creation of new ones until one is removed or the plan is updated.
  • In the case of monthly posts, the method calculates how many posts can still be scheduled or published within the current period, based on the subscription start date.

Implementing this functionality facilitates both the presentation of this information to the user and the performance of internal validations, promoting a better experience and management of contracted resources.

✌️ How do you aim to achieve this?

To achieve this goal, we want to implement the getRemainingQuota method in the PermissionsService class so that:

  • The method receives the organization identifier (orgId) and a specific section (such as CHANNEL, WEBHOOKS or POSTS_PER_MONTH).
  • Use the getPackageOptions method to obtain the limits defined in the subscription plan and, depending on the section, consult the responsible services (IntegrationService, WebhooksService or PostsService) to determine the current consumption of the resource.
  • For CHANNEL, the implementation should look for valid integrations, compare that number to the predefined limit (or the subscription's totalChannels, if higher), and return the remaining amount.
  • For WEBHOOKS, the method must obtain the current total of webhooks and return the difference in relation to the configured limit.
  • For POSTS_PER_MONTH, it must use the subscription creation date to determine the counting period, count the posts made since then and calculate how many posts can still be made.
  • In any other unspecified case, the method returns 0.

🔄️ Additional Information

No response

👀 Have you spent some time to check if this feature request has been raised before?

  • I checked and didn't find similar issue

Are you willing to submit PR?

None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant