-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Create api usage function (#3340)
- Loading branch information
Showing
14 changed files
with
506 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
API_USAGE_ALERT_THRESHOLDS = [75, 90, 100, 120] | ||
ALERT_EMAIL_MESSAGE = ( | ||
"Organisation %s has used %d seats which is over their plan limit of %d (plan: %s)" | ||
) | ||
ALERT_EMAIL_SUBJECT = "Organisation over number of seats" |
36 changes: 36 additions & 0 deletions
36
api/organisations/migrations/0051_create_org_api_usage_notification.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Generated by Django 3.2.23 on 2024-02-05 16:53 | ||
|
||
import django.core.validators | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('organisations', '0050_add_historical_subscription'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='organisationsubscriptioninformationcache', | ||
name='current_billing_term_ends_at', | ||
field=models.DateTimeField(null=True), | ||
), | ||
migrations.AddField( | ||
model_name='organisationsubscriptioninformationcache', | ||
name='current_billing_term_starts_at', | ||
field=models.DateTimeField(null=True), | ||
), | ||
migrations.CreateModel( | ||
name='OranisationAPIUsageNotification', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('percent_usage', models.IntegerField(validators=[django.core.validators.MinValueValidator(75), django.core.validators.MaxValueValidator(120)])), | ||
('notified_at', models.DateTimeField(null=True)), | ||
('created_at', models.DateTimeField(auto_now_add=True, null=True)), | ||
('updated_at', models.DateTimeField(auto_now=True, null=True)), | ||
('organisation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='api_usage_notifications', to='organisations.organisation')), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
api/organisations/templates/organisations/api_usage_notification.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<table> | ||
|
||
<tr> | ||
|
||
<td>Hi there,</td> | ||
|
||
</tr> | ||
|
||
<tr> | ||
|
||
<td> | ||
The API usage for {{ organisation.name }} has reached | ||
{{ matched_threshold }}% within the current subscription period. | ||
Please consider upgrading your organisations account limits. | ||
</td> | ||
|
||
|
||
</tr> | ||
|
||
<tr> | ||
|
||
<td>Thank you!</td> | ||
|
||
</tr> | ||
|
||
<tr> | ||
|
||
<td>The Flagsmith Team</td> | ||
|
||
</tr> | ||
|
||
</table> |
7 changes: 7 additions & 0 deletions
7
api/organisations/templates/organisations/api_usage_notification.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Hi there, | ||
|
||
The API usage for {{ organisation.name }} has reached {{ matched_threshold }}% within the current subscription period. Please consider upgrading your organisations account limits. | ||
|
||
Thank you! | ||
|
||
The Flagsmith Team |
Oops, something went wrong.