-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!--- Please provide a general summary of your changes in the title above --> # Pull Request type <!-- Please try to limit your pull request to one type; submit multiple pull requests if needed. --> Please check the type of change your PR introduces: - [x] Bugfix - [ ] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no API changes) - [ ] Build-related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior? <!-- Please describe the current behavior that you are modifying, or link to a relevant issue. --> Issue Number: N/A ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - - - ## Does this introduce a breaking change? - [ ] Yes - [ ] No <!-- If this does introduce a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR, such as screenshots of how the component looks before and after the change. --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a migration job for creating election alerts, enhancing the system's responsiveness to civic events. - Updated the `LocationBasedAlertBanner` component for improved styling and layout. - **Bug Fixes** - Downgraded several Prisma-related dependencies to address compatibility issues and improve stability. - **Documentation** - Enhanced the migration capabilities documentation through the addition of new export statements for better access. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
10 changed files
with
205 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
packages/db/prisma/data-migrations/2024-08-22_election-alert.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { addSingleKeyFromNestedFreetextCreate } from '@weareinreach/crowdin/api' | ||
import { generateNestedFreeText } from '~db/lib/generateFreeText' | ||
import { type MigrationJob } from '~db/prisma/dataMigrationRunner' | ||
import { type JobDef } from '~db/prisma/jobPreRun' | ||
/** Define the job metadata here. */ | ||
const jobDef: JobDef = { | ||
jobId: '2024-08-22_election-alert', | ||
title: 'election alert', | ||
createdBy: 'Joe Karow', | ||
/** Optional: Longer description for the job */ | ||
description: undefined, | ||
} | ||
/** | ||
* Job export - this variable MUST be UNIQUE | ||
*/ | ||
export const job20240822_election_alert = { | ||
title: `[${jobDef.jobId}] ${jobDef.title}`, | ||
task: async (ctx, task) => { | ||
const { createLogger, formatMessage, jobPostRunner, prisma } = ctx | ||
/** Create logging instance */ | ||
createLogger(task, jobDef.jobId) | ||
const log = (...args: Parameters<typeof formatMessage>) => (task.output = formatMessage(...args)) | ||
/** | ||
* Start defining your data migration from here. | ||
* | ||
* To log output, use `task.output = 'Message to log'` | ||
* | ||
* This will be written to `stdout` and to a log file in `/prisma/migration-logs/` | ||
*/ | ||
|
||
// Do stuff | ||
|
||
const alertId = 'alrt_01J5XNBQ5GREHSHK5D2QTCXRWE' | ||
|
||
const alertText = generateNestedFreeText({ | ||
type: 'locationAlert', | ||
freeTextId: 'ftxt_01J5XNC3P8HS8SWHGBB546D4RA', | ||
itemId: alertId, | ||
text: "🇺🇸 US Citizens: <Link href='https://www.headcount.org/vote-with-pride/'>Make sure you're registered and ready to vote with pride on November 5, 2024!</Link>", | ||
}) | ||
|
||
await prisma.$transaction(async (tx) => { | ||
const crowdIn = await addSingleKeyFromNestedFreetextCreate(alertText) | ||
|
||
const newAlert = await tx.locationAlert.create({ | ||
data: { | ||
id: alertId, | ||
level: 'WARN_PRIMARY', | ||
text: alertText, | ||
country: { | ||
connect: { cca2: 'US' }, | ||
// [ | ||
// { cca2: 'AS' }, | ||
// { cca2: 'GU' }, | ||
// { cca2: 'MH' }, | ||
// { cca2: 'MP' }, | ||
// { cca2: 'PR' }, | ||
// { cca2: 'PW' }, | ||
// { cca2: 'UM' }, | ||
// { cca2: 'US' }, | ||
// { cca2: 'VI' }, | ||
// ], | ||
}, | ||
}, | ||
}) | ||
log(`Created alert ${newAlert.id}. Crowdin id: ${crowdIn.id}`) | ||
}) | ||
|
||
/** | ||
* DO NOT REMOVE BELOW | ||
* | ||
* This writes a record to the DB to register that this migration has run successfully. | ||
*/ | ||
await jobPostRunner(jobDef) | ||
}, | ||
def: jobDef, | ||
} satisfies MigrationJob |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/db/prisma/migrations/20240827192047_location_alert_order/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- AlterTable | ||
ALTER TABLE "LocationAlert" | ||
ADD COLUMN "order" INTEGER NOT NULL DEFAULT 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.