Skip to content

fix(sql): Optimize getFreeSubscribersWaitingForMonthlyEmail #5939

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jbuck
Copy link
Member

@jbuck jbuck commented May 28, 2025

References:

Jira: MNTOR-
Figma:

Description

Screenshot (if applicable)

Not applicable.

How to test

Checklist (Definition of Done)

  • Localization strings (if needed) have been added.
  • Commits in this PR are minimal and have descriptive commit messages.
  • I've added or updated the relevant sections in readme and/or code comments
  • I've added a unit test to test for potential regressions of this bug.
  • If this PR implements a feature flag or experimentation, I've checked that it still works with the flag both on, and with the flag off.
  • If this PR implements a feature flag or experimentation, the Ship Behind Feature Flag status in Jira has been set
  • Product Owner accepted the User Story (demo of functionality completed) or waived the privilege.
  • All acceptance criteria are met.
  • Jira ticket has been updated (if needed) to match changes made during the development process.
  • Jira ticket has been updated (if needed) with suggestions for QA when this PR is deployed to stage.

@mansaj mansaj requested review from Vinnl and rhelmer May 29, 2025 17:06
@Vinnl
Copy link
Collaborator

Vinnl commented Jun 2, 2025

@rhelmer Would you mind if I defer to you for this one? Since you wrote the original query (#5431), which I don't fully comprehend :) I'd primarily look out for en-US matching us, and nl-BE not matching nl, for example.

@Vinnl Vinnl removed their request for review June 2, 2025 11:15
.andWhere((builder) =>
builder
.whereRaw(
`fxa_profile_json ->> 'locale' ~ '^..-(${countryCodes.join("|")})'`
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure a paramaterized query is used in this case, and I don't know if we can guarantee that countryCodes has been sanitized.

Copy link
Collaborator

Choose a reason for hiding this comment

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

To make sure it's parameterized I think something like this would work (untested):

.whereRaw(
  `fxa_profile_json ->> 'locale' ~ '^..-(' || ? || ')'`,
  [countryCodes.join("|")]
)

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.

3 participants