Skip to content

Commit

Permalink
feat: change boolean to date
Browse files Browse the repository at this point in the history
  • Loading branch information
mansaj committed Jan 13, 2025
1 parent 2ccec73 commit 16b7f56
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/db/tables/subscribers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,9 @@ async function markChurnPreventionEmailAsJustSent(
) {
const affectedSubscribers = await knex("subscribers")
.update({
churn_prevention_email_sent: true,
// @ts-ignore knex.fn.now() results in it being set to a date,
// even if it's not typed as a JS date object:
churn_prevention_email_sent_at: knex.fn.now(),
// @ts-ignore knex.fn.now() results in it being set to a date,
// even if it's not typed as a JS date object:
updated_at: knex.fn.now(),
Expand Down Expand Up @@ -696,11 +698,13 @@ async function isSubscriberPlus(subscriberId: SubscriberRow["id"]) {

// Not covered by tests; mostly side-effects. See test-coverage.md#mock-heavy
/* c8 ignore start */
async function getChurnPreventionEmailSent(subscriberId: SubscriberRow["id"]) {
async function getChurnPreventionEmailSentAt(
subscriberId: SubscriberRow["id"],
) {
const res = await knex("subscribers")
.select("churn_prevention_email_sent")
.select("churn_prevention_email_sent_at")
.where("id", subscriberId);
return res?.[0]?.["churn_prevention_email_sent"] ?? null;
return res?.[0]?.["churn_prevention_email_sent_at"] ?? null;
}
/* c8 ignore stop */

Expand Down Expand Up @@ -729,7 +733,7 @@ export {
deleteOnerepProfileId,
incrementSignInCountForEligibleFreeUser,
getSignInCount,
getChurnPreventionEmailSent,
getChurnPreventionEmailSentAt,
unresolveAllBreaches,
isSubscriberPlus,
knex as knexSubscribers,
Expand Down

0 comments on commit 16b7f56

Please sign in to comment.