Skip to content

Commit

Permalink
Merge pull request #4399 from mozilla/MNTOR-3079
Browse files Browse the repository at this point in the history
MNTOR-3079: add monthly report column
  • Loading branch information
mansaj authored Apr 17, 2024
2 parents 0788680 + 6a945ef commit 82c5861
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/app/functions/server/sanitize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export type SanitizedSubscriberRow = SanitizationMarker &
| "breaches_resolved"
| "waitlists_joined"
| "breach_stats"
| "monthly_email_optout"
| "monthly_monitor_report"
| "onerep_profile_id"
| "email_addresses"
>;
Expand Down Expand Up @@ -88,7 +88,7 @@ export function sanitizeSubscriberRow(
breaches_resolved: subscriber.breaches_resolved,
waitlists_joined: subscriber.waitlists_joined,
breach_stats: subscriber.breach_stats,
monthly_email_optout: subscriber.monthly_email_optout,
monthly_monitor_report: subscriber.monthly_monitor_report,
onerep_profile_id: subscriber.onerep_profile_id,
email_addresses: subscriber.email_addresses,
// If we want to avoid passing this property to the client-side, we can also
Expand Down
21 changes: 21 additions & 0 deletions src/db/migrations/20240408161125_add_monthly_report_column.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

export function up (knex) {
return knex.schema.table('subscribers', table => {
table.dropColumn("monthly_email_optout")
table.dropColumn("monthly_email_at")
table.boolean('monthly_monitor_report').defaultTo(true)
table.timestamp('monthly_monitor_report_at')
})
}

export function down (knex) {
return knex.schema.table('subscribers', table => {
table.boolean('monthly_email_optout')
table.timestamp('monthly_email_at')
table.dropColumn('monthly_monitor_report')
table.dropColumn("monthly_monitor_report_at")
})
}
1 change: 1 addition & 0 deletions src/db/seeds/testSubscribers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// OBSOLETE: Delete as a part of MNTOR-3077
'use strict'

import { getSha1 } from '../../utils/fxa.js'
Expand Down
4 changes: 4 additions & 0 deletions src/db/tables/subscribers.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ async function updateMonthlyEmailTimestamp (email) {
/* c8 ignore stop */

/**
* OBSOLETE: Delete as a part of MNTOR-3077
* Unsubscribe user from monthly unresolved breach emails
*
* @param {string} token User verification token
Expand All @@ -318,6 +319,7 @@ async function getOnerepProfileId (subscriberId) {
}
/* c8 ignore stop */

// OBSOLETE: Delete as a part of MNTOR-3077
// Not covered by tests; mostly side-effects. See test-coverage.md#mock-heavy
/* c8 ignore start */
function getSubscribersWithUnresolvedBreachesQuery () {
Expand All @@ -328,6 +330,7 @@ function getSubscribersWithUnresolvedBreachesQuery () {
}
/* c8 ignore stop */

// OBSOLETE: Delete as a part of MNTOR-3077
// Not covered by tests; mostly side-effects. See test-coverage.md#mock-heavy
/* c8 ignore start */
async function getSubscribersWithUnresolvedBreaches (limit = 0) {
Expand All @@ -340,6 +343,7 @@ async function getSubscribersWithUnresolvedBreaches (limit = 0) {
}
/* c8 ignore stop */

// OBSOLETE: Delete as a part of MNTOR-3077
// Not covered by tests; mostly side-effects. See test-coverage.md#mock-heavy
/* c8 ignore start */
async function getSubscribersWithUnresolvedBreachesCount () {
Expand Down
8 changes: 4 additions & 4 deletions src/knex-tables.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ declare module "knex/types/tables" {
};
// TODO: Find unknown type
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
monthly_email_at: null | unknown;
monthly_monitor_report_at: null | unknown;
// TODO: Find unknown type
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
monthly_email_optout: null | unknown;
monthly_monitor_report: boolean;
breach_resolution:
| null
| ({
Expand Down Expand Up @@ -149,8 +149,8 @@ declare module "knex/types/tables" {
| "breaches_resolved"
| "waitlists_joined"
| "breach_stats"
| "monthly_email_at"
| "monthly_email_optout"
| "monthly_monitor_report_at"
| "monthly_monitor_report"
| "breach_resolution"
| "db_migration_1"
| "db_migration_2"
Expand Down

0 comments on commit 82c5861

Please sign in to comment.