Skip to content

Commit

Permalink
Migrate "delete unverified subscribers" cron to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinnl committed Jul 11, 2024
1 parent 94bd52e commit 96bc287
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions docs/dependency-updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ Used to compile cronjob scripts. You can test this by running
### `tsx`

Used to run cronjobs locally and compile them on the fly. You can verify this by
running `npm run dev:cronjobs`; if the cronjobs run like in `main`, it's still
working.
running a cronjob like `npm run dev:cron:monthly-activity`; if the cronjobs run
like in `main`, it's still working.

### `yaml`

Expand Down
2 changes: 1 addition & 1 deletion esbuild.cronjobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { build } from "esbuild";
// own issues in Next.js. Thus, esbuild is a compromise that can resolve these
// import specifiers for us.
build({
entryPoints: ["./src/scripts/cronjobs/**/*.tsx"],
entryPoints: ["./src/scripts/cronjobs/**/*.tsx", "./src/scripts/cronjobs/**/*.ts"],
tsconfig: "tsconfig.cronjobs.json",
bundle: true,
platform: "node",
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"type": "module",
"scripts": {
"dev": "npm run build-nimbus && next dev --port=6060",
"dev:cronjobs": "tsx --tsconfig tsconfig.cronjobs.json src/scripts/cronjobs/*.tsx",
"dev:cron:first-data-broker-removal-fixed": "tsx --tsconfig tsconfig.cronjobs.json src/scripts/cronjobs/firstDataBrokerRemovalFixed.tsx",
"dev:cron:monthly-activity": "tsx --tsconfig tsconfig.cronjobs.json src/scripts/cronjobs/monthlyActivity.tsx",
"dev:cron:db-delete-unverified-subscribers": "tsx --tsconfig tsconfig.cronjobs.json src/scripts/cronjobs/deleteUnverifiedSubscribers.ts",
"dev:nimbus": "node --watch-path config/nimbus.yaml src/scripts/build/nimbusTypes.js",
"build": "npm run get-location-data && npm run build-glean && npm run build-nimbus && next build && npm run build-cronjobs",
"cloudrun": "npm run db:migrate && npm start",
Expand All @@ -23,7 +25,7 @@
"cron:first-data-broker-removal-fixed": "node dist/scripts/cronjobs/firstDataBrokerRemovalFixed.js",
"cron:monthly-activity": "node dist/scripts/cronjobs/monthlyActivity.js",
"cron:breach-alerts": "node src/scripts/emailBreachAlerts.js",
"cron:db-delete-unverified-subscribers": "node scripts/delete-unverified-subscribers.js",
"cron:db-delete-unverified-subscribers": "node dist/scripts/cronjobs/deleteUnverifiedSubscribers.js",
"cron:db-pull-breaches": "node src/scripts/syncBreaches.js",
"cron:remote-settings-pull-breaches": "node scripts/updatebreaches.js",
"cron:onerep-limits-alert": "node src/scripts/onerepStatsAlert.js",
Expand Down
12 changes: 0 additions & 12 deletions scripts/delete-unverified-subscribers.js

This file was deleted.

12 changes: 12 additions & 0 deletions src/scripts/cronjobs/deleteUnverifiedSubscribers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use strict";

import { deleteUnverifiedSubscribers } from "../../db/tables/subscribers";

/**
* Cron: Hourly
* Delete any records of subscribers not verified within 24 hrs
*/
(async () => {
await deleteUnverifiedSubscribers();
process.exit();
})();

0 comments on commit 96bc287

Please sign in to comment.