-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
03-ethnicity.ts
59 lines (53 loc) · 1.17 KB
/
03-ethnicity.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { prisma } from '~/index'
import { logFile } from '../logger'
import { ListrTask } from '../starterData'
import { keySlug, namespaces } from './00-namespaces'
type EthnicityData = string[]
const ethnicityData: EthnicityData = [
'Black',
'Middle Eastern/North African',
'Asian',
'Latino/a/x/Hispanic',
'South Asian',
'Biracial/Multiracial',
'American Indian/Native American/Indigenous Person',
'Native Hawaiian/Pacific Islander',
'White',
'Other',
'Prefer not to say',
]
export const generateEthnicityRecords = (task: ListrTask) => {
const queue = ethnicityData.map((item, i) => {
const logMessage = `(${i}/${ethnicityData.length}) Added Ethnicity transaction to queue: ${item}`
logFile.log(logMessage)
task.output = logMessage
return prisma.userEthnicity.upsert({
where: {
ethnicity: item,
},
create: {
ethnicity: item,
key: {
create: {
key: `eth-${keySlug(item)}`,
text: item,
namespace: {
connect: {
name: namespaces.user,
},
},
},
},
},
update: {
key: {
update: {
key: `eth-${keySlug(item)}`,
text: item,
},
},
},
})
})
return queue
}