Skip to content

Commit

Permalink
feat(app): ECB-54: update food service tags, add "Hot meals" tag (#1447)
Browse files Browse the repository at this point in the history
<!--- 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?

most of the existing food service options are not selectable when
updating org services and offerings

Issue Number: N/A

## What is the new behavior?
this PR changes the active flag to tru so the services can be configured
via a db migration
this PR add a new food service tag called "Hot meals" via db migration
as well as an addition to the language file

-
-
-

## 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 Jan 15, 2025
2 parents caf78a5 + 561398d commit 0a5a914
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/app/public/locales/en/services.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"food-assistance": "Food assistance",
"food-delivery": "Food delivery",
"food-pantries": "Food pantries",
"hot-meals": "Hot meals",
"nutrition-education": "Nutrition education"
},
"housing": {
Expand Down
1 change: 1 addition & 0 deletions apps/app/public/locales/ht/services.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"food-assistance": "Asistans manje",
"food-delivery": "Food delivery",
"food-pantries": "Food pantries",
"hot-meals": "Hot meals",
"nutrition-education": "Nutrition education"
},
"housing": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { type MigrationJob } from '~db/prisma/dataMigrationRunner'
import { type JobDef } from '~db/prisma/jobPreRun'

/** Define the job metadata here. */
const jobDef: JobDef = {
jobId: '2025-01-15_new-food-service-tags',
title: 'new service tags',
createdBy: 'Diana Garbarino',
/** Optional: Longer description for the job */
description: undefined,
}
/**
* Job export - this variable MUST be UNIQUE
*/
export const job20250115_new_food_service_tags = {
title: `[${jobDef.jobId}] ${jobDef.title}`,
task: async (ctx, task) => {
const { createLogger, downloadFromDatastore, generateId, 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 hotMeals = await prisma.serviceTag.create({
data: {
id: 'svtg_01GW2HHFBZ4D5XHQJSN29GF8TZ7',
name: 'Hot meals',
active: true,
categories: {
create: { active: true, category: { connect: { id: 'svct_01GW2HHEVFXW9YFMK4R95ZHBPV' } } },
},
primaryCategory: { connect: { id: 'svct_01GW2HHEVFXW9YFMK4R95ZHBPV' } },
key: {
create: {
key: 'food.hot-meals',
text: 'Hot meals',
namespace: { connect: { name: 'services' } },
},
},
},
})
log(`Created service tag: ${hotMeals.name} (${hotMeals.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
74 changes: 74 additions & 0 deletions packages/db/prisma/data-migrations/2025-01-15_update-food-tags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { type MigrationJob } from '~db/prisma/dataMigrationRunner'
import { type JobDef } from '~db/prisma/jobPreRun'

/** Define the job metadata here. */
const jobDef: JobDef = {
jobId: '2025-01-15_update-food-tags-to-active',
title: 'update food tags to active',
createdBy: 'Diana Garbarino',
/** Optional: Longer description for the job */
description: undefined,
}
/**
* Job export - this variable MUST be UNIQUE
*/
export const job20250115_update_food_tags_to_active = {
title: `[${jobDef.jobId}] ${jobDef.title}`,
task: async (ctx, task) => {
const { createLogger, downloadFromDatastore, generateId, 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 update = await prisma.$transaction([
prisma.serviceTag.update({
where: { id: 'svtg_01J1GDWBVVQ9BBBWMDW3J8J4MT' },
data: {
active: true,
},
}),
prisma.serviceTag.update({
where: { id: 'svtg_01J1GDWBWJKRP2H2NC84CXAERQ' },
data: {
active: true,
},
}),
prisma.serviceTag.update({
where: { id: 'svtg_01J1GDWBWZJAKK8GBQ9GECY6W6' },
data: {
active: true,
},
}),
prisma.serviceTag.update({
where: { id: 'svtg_01J1GDWBXBWPMPZCNAYNCGEHYP' },
data: {
active: true,
},
}),
prisma.serviceTag.update({
where: { id: 'svtg_01J1GDWBXYEJX7RJP7XRXJYPAH' },
data: {
active: true,
},
}),
])
log(`serviceTag records updated: ${update.length}`)

/**
* 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
2 changes: 2 additions & 0 deletions packages/db/prisma/data-migrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ export * from './2024-07-29_new-service-tags'
export * from './2024-08-22_election-alert'
export * from './2024-12-22_update-alert-link'
export * from './2025-01-07_update-locationbased-alert-string'
export * from './2025-01-15_new_food-service-tag'
export * from './2025-01-15_update-food-tags'
// codegen:end

0 comments on commit 0a5a914

Please sign in to comment.