Skip to content

Commit

Permalink
Improve rate-limit email title (#564)
Browse files Browse the repository at this point in the history
Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com>
  • Loading branch information
dotansimha and kamilkisiela authored Nov 10, 2022
1 parent 3cd155e commit c4a0cac
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions integration-tests/tests/api/rate-limit/emails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ function generateUnique() {
}

function filterEmailsByOrg(orgName: string, emails: emails.Email[]) {
return emails.filter(email => email.subject.startsWith(orgName));
return emails
.filter(email => email.subject.includes(orgName))
.map(email => ({
subject: email.subject,
email: email.to,
}));
}

test('rate limit approaching and reached for organization', async () => {
Expand Down Expand Up @@ -101,7 +106,7 @@ test('rate limit approaching and reached for organization', async () => {

expect(sent).toContainEqual({
to: adminEmail,
subject: `${org.name} has exceeded its rate limit`,
subject: `GraphQL-Hive operations quota for ${org.name} exceeded`,
body: expect.any(String),
});
expect(filterEmailsByOrg(org.name, sent)).toHaveLength(2);
Expand Down
4 changes: 2 additions & 2 deletions packages/services/rate-limit/src/emails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function createEmailScheduler(config?: { endpoint: string }) {
period: input.period,
limit: input.usage.quota,
}),
subject: `${input.organization.name} has exceeded its rate limit`,
subject: `GraphQL-Hive operations quota for ${input.organization.name} exceeded`,
body: `
<mjml>
<mj-body>
Expand All @@ -59,7 +59,7 @@ export function createEmailScheduler(config?: { endpoint: string }) {
<mj-image width="150px" src="https://graphql-hive.com/logo.png"></mj-image>
<mj-divider border-color="#ca8a04"></mj-divider>
<mj-text>
Your organization <strong>${
Your Hive organization <strong>${
input.organization.name
}</strong> has reached over 100% of the operations limit quota.
Used ${numberFormatter.format(input.usage.current)} of ${numberFormatter.format(input.usage.quota)}.
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c4a0cac

Please sign in to comment.