Skip to content

Commit

Permalink
feat(app): (ECB-63)[https://inreach.atlassian.net/browse/ECB-63]: Upd…
Browse files Browse the repository at this point in the history
…ate anti-trans risk map link (search results banner alert) (#1439)

<!--- 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:

- [ ] Bugfix
- [x] 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?
the anti-trans map link is outdated

Issue Number: N/A

## What is the new behavior?

updated anti-trans map link with newer data

-
-
-

## Does this introduce a breaking change?

- [ ] Yes
- [x] 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. -->
  • Loading branch information
trigal2012 authored Dec 23, 2024
2 parents c718ce9 + a351a56 commit a6da901
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
64 changes: 64 additions & 0 deletions packages/db/prisma/data-migrations/2024-12-22_update-alert-link.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
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-12-22_update-alert-link',
title: 'Update alert link',
createdBy: 'Diana Garbarino',
/** Optional: Longer description for the job */
description: 'This migration script updates the alert text with a new link.',
}

/**
* Job export - this variable MUST be UNIQUE
*/
export const job20241222_update_alert_link = {
title: `[${jobDef.jobId}] ${jobDef.title}`,
task: async (ctx, task) => {
const { createLogger, jobPostRunner, prisma, formatMessage } = ctx
/** Create logging instance */
createLogger(task, jobDef.jobId)
const log = (...args: Parameters<typeof formatMessage>) => (task.output = formatMessage(...args))

// Log that the script has started
log('Starting to update the alert link.')

// Define the alertId you wish to update
const alertId = 'alrt_01J1D1GAT5G5S6QNMCND5PMDAX'

// Fetch the existing alert record
const existingAlert = await prisma.locationAlert.findUnique({
where: { id: alertId },
})

if (!existingAlert) {
log(`Alert with ID ${alertId} not found.`)
return
}

// Update the 'text' field with a new link
const updatedAlert = await prisma.locationAlert.update({
where: { id: alertId },
data: {
text: generateNestedFreeText({
type: 'locationAlert',
freeTextId: existingAlert.text.freeTextId, // Retain the same freeTextId to avoid changing other content
itemId: alertId,
text: 'This <Link href="https://www.newlink.com">new anti-trans legislative risk map</Link> shows updated risk information.',
}),
},
})

log(`Updated alert ${updatedAlert.id} with new link`)

/**
* 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
1 change: 1 addition & 0 deletions packages/db/prisma/data-migrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export * from './2024-06-28_new-cost-props'
export * from './2024-07-29_address-visibility-update'
export * from './2024-07-29_new-service-tags'
export * from './2024-08-22_election-alert'
export * from './2024-12-22_update-alert-link'
// codegen:end

0 comments on commit a6da901

Please sign in to comment.