@bslau/hmm_prisma_schema 1.3.3 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/prisma/seed.ts CHANGED
@@ -2,610 +2,724 @@ import _ from "underscore";
2
2
  import prisma from "./dbClient";
3
3
 
4
4
  async function main() {
5
- // SEED: Station
6
- if (await prisma.station.count() > 0) {
7
- console.log("SEED: Station - skipped.");
8
- } else {
9
- console.log("SEED: Station - generating...");
5
+ // SEED: Station
6
+ if ((await prisma.station.count()) > 0) {
7
+ console.log("SEED: Station - skipped.");
8
+ } else {
9
+ console.log("SEED: Station - generating...");
10
10
 
11
- const createHolding = await prisma.station.create({
12
- data: {
13
- value: "HOLDING",
14
- name: "Holding",
15
- locations: {
16
- connectOrCreate: [
17
- {
18
- where: {
19
- value: "WPR",
20
- },
21
- create: {
22
- value: "WPR",
23
- name: "Woodpecker Repair Lines",
11
+ const createHolding = await prisma.station.create({
12
+ data: {
13
+ value: "HOLDING",
14
+ name: "Holding",
15
+ locations: {
16
+ connectOrCreate: [
17
+ {
18
+ where: {
19
+ value: "WPR",
20
+ },
21
+ create: {
22
+ value: "WPR",
23
+ name: "Woodpecker Repair Lines",
24
+ },
25
+ },
26
+ {
27
+ where: {
28
+ value: "5OL",
29
+ },
30
+ create: {
31
+ value: "5OL",
32
+ name: "5 Outside Loop",
33
+ },
34
+ },
35
+ {
36
+ where: {
37
+ value: "5BF",
38
+ },
39
+ create: {
40
+ value: "5BF",
41
+ name: "5 Blast Furnace",
42
+ },
43
+ },
44
+ {
45
+ where: {
46
+ value: "OPM",
47
+ },
48
+ create: {
49
+ value: "OPM",
50
+ name: "Old Plug Mill",
51
+ },
52
+ },
53
+ {
54
+ where: {
55
+ value: "XOVR",
56
+ },
57
+ create: {
58
+ value: "XOVR",
59
+ name: "Short Cross Over",
60
+ },
61
+ },
62
+ {
63
+ where: {
64
+ value: "5ML",
65
+ },
66
+ create: {
67
+ value: "5ML",
68
+ name: "5 BF Middle Loop",
69
+ },
70
+ },
71
+ {
72
+ where: {
73
+ value: "6BF",
74
+ },
75
+ create: {
76
+ value: "6BF",
77
+ name: "6 Blast Furnace",
78
+ },
79
+ },
80
+ {
81
+ where: {
82
+ value: "DSML",
83
+ },
84
+ create: {
85
+ value: "DSML",
86
+ name: "Desulph Main Line",
87
+ },
88
+ },
89
+ ],
90
+ },
91
+ },
92
+ });
93
+ const create5BFE = await prisma.station.create({
94
+ data: {
95
+ value: "5BFE",
96
+ name: "5 Blast Furnace - East",
97
+ locations: {
98
+ connectOrCreate: [
99
+ {
100
+ where: {
101
+ value: "5BFE",
102
+ },
103
+ create: {
104
+ value: "5BFE",
105
+ name: "5 Blast Furnace - East",
106
+ },
107
+ },
108
+ ],
109
+ },
110
+ },
111
+ });
112
+ const create5BFN = await prisma.station.create({
113
+ data: {
114
+ value: "5BFN",
115
+ name: "5 Blast Furnace - North",
116
+ locations: {
117
+ connectOrCreate: [
118
+ {
119
+ where: {
120
+ value: "5BFN",
121
+ },
122
+ create: {
123
+ value: "5BFN",
124
+ name: "5 Blast Furnace - North",
125
+ },
126
+ },
127
+ ],
128
+ },
129
+ },
130
+ });
131
+ const create5BFW = await prisma.station.create({
132
+ data: {
133
+ value: "5BFW",
134
+ name: "5 Blast Furnace - West",
135
+ locations: {
136
+ connectOrCreate: [
137
+ {
138
+ where: {
139
+ value: "5BFW",
140
+ },
141
+ create: {
142
+ value: "5BFW",
143
+ name: "5 Blast Furnace - West",
144
+ },
145
+ },
146
+ ],
147
+ },
148
+ },
149
+ });
150
+ const createDES1 = await prisma.station.create({
151
+ data: {
152
+ value: "DES1",
153
+ name: "Desulphurisation 1",
154
+ locations: {
155
+ connectOrCreate: [
156
+ {
157
+ where: {
158
+ value: "DES1",
159
+ },
160
+ create: {
161
+ value: "DES1",
162
+ name: "Desulphurisation 1",
163
+ },
164
+ },
165
+ ],
166
+ },
167
+ },
168
+ });
169
+ const createDES2 = await prisma.station.create({
170
+ data: {
171
+ value: "DES2",
172
+ name: "Desulphurisation 2",
173
+ locations: {
174
+ connectOrCreate: [
175
+ {
176
+ where: {
177
+ value: "DES2",
178
+ },
179
+ create: {
180
+ value: "DES2",
181
+ name: "Desulphurisation 2",
182
+ },
183
+ },
184
+ ],
185
+ },
186
+ },
187
+ });
188
+ const create6PIT = await prisma.station.create({
189
+ data: {
190
+ value: "6PIT",
191
+ name: "6 Pit",
192
+ locations: {
193
+ connectOrCreate: [
194
+ {
195
+ where: {
196
+ value: "6PIT",
197
+ },
198
+ create: {
199
+ value: "6PIT",
200
+ name: "6 Pit",
201
+ },
202
+ },
203
+ ],
204
+ },
205
+ },
206
+ });
207
+ const createWB1 = await prisma.station.create({
208
+ data: {
209
+ value: "WB1",
210
+ name: "Weighbridge 1",
211
+ locations: {
212
+ connectOrCreate: [
213
+ {
214
+ where: {
215
+ value: "WB1",
216
+ },
217
+ create: {
218
+ value: "WB1",
219
+ name: "Weighbridge 1",
220
+ },
221
+ },
222
+ ],
223
+ },
224
+ },
225
+ });
226
+ const createWB2 = await prisma.station.create({
227
+ data: {
228
+ value: "WB2",
229
+ name: "Weighbridge 2",
230
+ locations: {
231
+ connectOrCreate: [
232
+ {
233
+ where: {
234
+ value: "WB2",
235
+ },
236
+ create: {
237
+ value: "WB2",
238
+ name: "Weighbridge 2",
239
+ },
240
+ },
241
+ ],
242
+ },
243
+ },
244
+ });
245
+ const create21D = await prisma.station.create({
246
+ data: {
247
+ value: "21D",
248
+ name: "Dump",
249
+ locations: {
250
+ connectOrCreate: [
251
+ {
252
+ where: {
253
+ value: "21D",
254
+ },
255
+ create: {
256
+ value: "21D",
257
+ name: "Dump",
258
+ },
259
+ },
260
+ ],
261
+ },
262
+ },
263
+ });
264
+ const createWB1H = await prisma.station.create({
265
+ data: {
266
+ value: "WB1H",
267
+ name: "Weighbridge 1 - Holding",
268
+ locations: {
269
+ connectOrCreate: [
270
+ {
271
+ where: {
272
+ value: "WB1H",
273
+ },
274
+ create: {
275
+ value: "WB1H",
276
+ name: "Weighbridge 1 - Holding",
277
+ },
278
+ },
279
+ ],
280
+ },
281
+ },
282
+ });
283
+ const createWB2H = await prisma.station.create({
284
+ data: {
285
+ value: "WB2H",
286
+ name: "Weighbridge 2 - Holding",
287
+ locations: {
288
+ connectOrCreate: [
289
+ {
290
+ where: {
291
+ value: "WB2H",
292
+ },
293
+ create: {
294
+ value: "WB2H",
295
+ name: "Weighbridge 2 - Holding",
296
+ },
297
+ },
298
+ ],
299
+ },
300
+ },
301
+ });
302
+ const createGAS = await prisma.station.create({
303
+ data: {
304
+ value: "GAS",
305
+ name: "On Gas",
306
+ locations: {
307
+ connectOrCreate: [
308
+ {
309
+ where: {
310
+ value: "GASL",
311
+ },
312
+ create: {
313
+ value: "GASL",
314
+ name: "Gasline",
315
+ },
316
+ },
317
+ {
318
+ where: {
319
+ value: "COOL",
320
+ },
321
+ create: {
322
+ value: "COOL",
323
+ name: "Cooling Station",
324
+ },
325
+ },
326
+ {
327
+ where: {
328
+ value: "5BFHL",
329
+ },
330
+ create: {
331
+ value: "5BFHL",
332
+ name: "No.5 Blast Furnace Heating line",
333
+ },
334
+ },
335
+ ],
336
+ },
337
+ },
338
+ });
339
+ const createOOS = await prisma.station.create({
340
+ data: {
341
+ value: "OOS",
342
+ name: "Out Of Service",
343
+ locations: {
344
+ connectOrCreate: [
345
+ {
346
+ where: {
347
+ value: "GASL",
348
+ },
349
+ create: {
350
+ value: "GASL",
351
+ name: "Gasline",
352
+ },
353
+ },
354
+ {
355
+ where: {
356
+ value: "COOL",
357
+ },
358
+ create: {
359
+ value: "COOL",
360
+ name: "Cooling Station",
361
+ },
362
+ },
363
+ {
364
+ where: {
365
+ value: "5BFHL",
366
+ },
367
+ create: {
368
+ value: "5BFHL",
369
+ name: "No.5 Blast Furnace Heating line",
370
+ },
371
+ },
372
+ {
373
+ where: {
374
+ value: "5FDRY",
375
+ },
376
+ create: {
377
+ value: "5FDRY",
378
+ name: "No.5 position Foundry",
379
+ },
380
+ },
381
+ {
382
+ where: {
383
+ value: "GUNR",
384
+ },
385
+ create: {
386
+ value: "GUNR",
387
+ name: "Gunning Road",
388
+ },
389
+ },
390
+ {
391
+ where: {
392
+ value: "AWNR",
393
+ },
394
+ create: {
395
+ value: "AWNR",
396
+ name: "Awning Road",
397
+ },
398
+ },
399
+ {
400
+ where: {
401
+ value: "REBS",
402
+ },
403
+ create: {
404
+ value: "REBS",
405
+ name: "Rebrick shed",
406
+ },
407
+ },
408
+ {
409
+ where: {
410
+ value: "LRS1",
411
+ },
412
+ create: {
413
+ value: "LRS1",
414
+ name: "Ladle Repair shop road 1",
415
+ },
416
+ },
417
+ {
418
+ where: {
419
+ value: "LRS2",
420
+ },
421
+ create: {
422
+ value: "LRS2",
423
+ name: "Ladle Repair shop road 2",
424
+ },
425
+ },
426
+ {
427
+ where: {
428
+ value: "KLO",
429
+ },
430
+ create: {
431
+ value: "KLO",
432
+ name: "Klondu",
433
+ },
434
+ },
435
+ ],
436
+ },
437
+ },
438
+ });
439
+ const createRM = await prisma.station.create({
440
+ data: {
441
+ value: "R+M/BREAK",
442
+ name: "R+M / Break",
443
+ locations: {
444
+ connectOrCreate: [
445
+ {
446
+ where: {
447
+ value: "LRS1",
448
+ },
449
+ create: {
450
+ value: "LRS1",
451
+ name: "Ladle Repair shop road 1",
452
+ },
453
+ },
454
+ {
455
+ where: {
456
+ value: "LRS2",
457
+ },
458
+ create: {
459
+ value: "LRS2",
460
+ name: "Ladle Repair shop road 2",
461
+ },
462
+ },
463
+ ],
464
+ },
465
+ },
466
+ });
24
467
 
25
- }
26
- },
27
- {
28
- where: {
29
- value: "5OL",
30
- },
31
- create: {
32
- value: "5OL",
33
- name: "5 Outside Loop",
34
- }
35
- },
36
- {
37
- where: {
38
- value: "5BF",
39
- },
40
- create: {
41
- value: "5BF",
42
- name: "5 Blast Furnace",
43
- }
44
- },
45
- {
46
- where: {
47
- value: "OPM",
48
- },
49
- create: {
50
- value: "OPM",
51
- name: "Old Plug Mill",
52
- }
53
- },
54
- {
55
- where: {
56
- value: "XOVR",
57
- },
58
- create: {
59
- value: "XOVR",
60
- name: "Short Cross Over",
61
- }
62
- },
63
- {
64
- where: {
65
- value: "5ML",
66
- },
67
- create: {
68
- value: "5ML",
69
- name: "5 BF Middle Loop",
70
- }
71
- },
72
- {
73
- where: {
74
- value: "6BF",
75
- },
76
- create: {
77
- value: "6BF",
78
- name: "6 Blast Furnace",
79
- }
80
- },
81
- {
82
- where: {
83
- value: "DSML",
84
- },
85
- create: {
86
- value: "DSML",
87
- name: "Desulph Main Line",
88
- }
89
- },
90
- ],
91
- }
92
- }
93
- })
94
- const create5BFE = await prisma.station.create({
95
- data: {
96
- value: "5BFE",
97
- name: "5 Blast Furnace - East",
98
- locations: {
99
- connectOrCreate: [
100
- {
101
- where: {
102
- value: "5BFE",
103
- },
104
- create:
105
- {
106
- value: "5BFE",
107
- name: "5 Blast Furnace - East",
108
- }
109
- },
110
- ]
468
+ console.log({
469
+ create21D,
470
+ create5BFE,
471
+ create5BFN,
472
+ create5BFW,
473
+ create6PIT,
474
+ createDES1,
475
+ createDES2,
476
+ createGAS,
477
+ createHolding,
478
+ createOOS,
479
+ createRM,
480
+ createWB1,
481
+ createWB1H,
482
+ createWB2,
483
+ createWB2H,
484
+ });
111
485
 
112
- }
113
- }
114
- })
115
- const create5BFN = await prisma.station.create({
116
- data: {
117
- value: "5BFN",
118
- name: "5 Blast Furnace - North",
119
- locations: {
120
- connectOrCreate: [
121
- {
122
- where: {
123
- value: "5BFN",
124
- },
125
- create: {
126
- value: "5BFN",
127
- name: "5 Blast Furnace - North",
128
- }
129
- },
130
- ]
131
- }
132
- },
133
- })
134
- const create5BFW = await prisma.station.create({
135
- data: {
136
- value: "5BFW",
137
- name: "5 Blast Furnace - West",
138
- locations: {
139
- connectOrCreate: [
140
- {
141
- where: {
142
- value: "5BFW",
143
- },
144
- create: {
145
- value: "5BFW",
146
- name: "5 Blast Furnace - West",
147
- }
148
- },
149
- ]
150
- }
151
- },
152
- })
153
- const createDES1 = await prisma.station.create({
154
- data: {
155
- value: "DES1",
156
- name: "Desulphurisation 1",
157
- locations: {
158
- connectOrCreate: [
159
- {
160
- where: {
161
- value: "DES1",
162
- },
163
- create: {
164
- value: "DES1",
165
- name: "Desulphurisation 1",
166
- }
167
- },
168
- ]
169
- }
170
- },
171
- })
172
- const createDES2 = await prisma.station.create({
173
- data: {
174
- value: "DES2",
175
- name: "Desulphurisation 2",
176
- locations: {
177
- connectOrCreate: [
178
- {
179
- where: {
180
- value: "DES2",
181
- },
182
- create: {
183
- value: "DES2",
184
- name: "Desulphurisation 2",
185
- }
186
- },
187
- ]
188
- }
189
- },
190
- })
191
- const create6PIT = await prisma.station.create({
192
- data: {
193
- value: "6PIT",
194
- name: "6 Pit",
195
- locations: {
196
- connectOrCreate: [
197
- {
198
- where: {
199
- value: "6PIT",
200
- },
201
- create: {
202
- value: "6PIT",
203
- name: "6 Pit",
204
- }
205
- },
206
- ]
207
- }
208
- },
209
- })
210
- const createWB1 = await prisma.station.create({
211
- data: {
212
- value: "WB1",
213
- name: "Weighbridge 1",
214
- locations: {
215
- connectOrCreate: [
216
- {
217
- where: {
218
- value: "WB1",
219
- },
220
- create: {
221
- value: "WB1",
222
- name: "Weighbridge 1",
223
- }
224
- },
225
- ]
226
- }
227
- },
228
- })
229
- const createWB2 = await prisma.station.create({
230
- data: {
231
- value: "WB2",
232
- name: "Weighbridge 2",
233
- locations: {
234
- connectOrCreate: [
235
- {
236
- where: {
237
- value: "WB2",
238
- },
239
- create: {
240
- value: "WB2",
241
- name: "Weighbridge 2",
242
- }
243
- },
244
- ]
245
- }
246
- },
247
- })
248
- const create21D = await prisma.station.create({
249
- data: {
250
- value: "21D",
251
- name: "Dump",
252
- locations: {
253
- connectOrCreate: [
254
- {
255
- where: {
256
- value: "21D",
257
- },
258
- create: {
259
- value: "21D",
260
- name: "Dump",
261
- }
262
- },
263
- ]
264
- }
265
- },
266
- })
267
- const createWB1H = await prisma.station.create({
268
- data: {
269
- value: "WB1H",
270
- name: "Weighbridge 1 - Holding",
271
- locations: {
272
- connectOrCreate: [
273
- {
274
- where: {
275
- value: "WB1H",
276
- },
277
- create: {
278
- value: "WB1H",
279
- name: "Weighbridge 1 - Holding",
280
- }
281
- },
282
- ]
283
- }
284
- },
285
- })
286
- const createWB2H = await prisma.station.create({
287
- data: {
288
- value: "WB2H",
289
- name: "Weighbridge 2 - Holding",
290
- locations: {
291
- connectOrCreate: [
292
- {
293
- where: {
294
- value: "WB2H",
295
- },
296
- create: {
297
- value: "WB2H",
298
- name: "Weighbridge 2 - Holding",
299
- }
300
- },
301
- ]
302
- }
303
- },
304
- })
305
- const createGAS = await prisma.station.create({
306
- data: {
307
- value: "GAS",
308
- name: "On Gas",
309
- locations: {
310
- connectOrCreate: [
311
- {
312
- where: {
313
- value: "GASL",
314
- },
315
- create: {
316
- value: "GASL",
317
- name: "Gasline",
318
- }
319
- },
320
- {
321
- where: {
322
- value: "COOL"
323
- },
324
- create: {
325
- value: "COOL",
326
- name: "Cooling Station",
327
- }
328
- },
329
- {
330
- where: {
331
- value: "5BFHL",
332
- },
333
- create: {
334
- value: "5BFHL",
335
- name: "No.5 Blast Furnace Heating line",
336
- }
337
- }
338
- ]
339
- }
340
- },
341
- })
342
- const createOOS = await prisma.station.create({
343
- data: {
344
- value: "OOS",
345
- name: "Out Of Service",
346
- locations: {
347
- connectOrCreate: [
348
- {
349
- where: {
350
- value: "GASL",
351
- },
352
- create: {
353
- value: "GASL",
354
- name: "Gasline",
355
- }
356
- },
357
- {
358
- where: {
359
- value: "COOL"
360
- },
361
- create: {
362
- value: "COOL",
363
- name: "Cooling Station",
364
- }
365
- },
366
- {
367
- where: {
368
- value: "5BFHL",
369
- },
370
- create: {
371
- value: "5BFHL",
372
- name: "No.5 Blast Furnace Heating line",
373
- }
374
- },
375
- {
376
- where: {
377
- value: "5FDRY",
378
- },
379
- create: {
380
- value: "5FDRY",
381
- name: "No.5 position Foundry",
382
- }
383
- },
384
- {
385
- where: {
386
- value: "GUNR",
387
- },
388
- create: {
389
- value: "GUNR",
390
- name: "Gunning Road",
391
- }
392
- },
393
- {
394
- where: {
395
- value: "AWNR",
396
- },
397
- create: {
398
- value: "AWNR",
399
- name: "Awning Road",
400
- }
401
- },
402
- {
403
- where: {
404
- value: "REBS",
405
- },
406
- create: {
407
- value: "REBS",
408
- name: "Rebrick shed",
409
- }
410
- },
411
- {
412
- where: {
413
- value: "LRS1",
414
- },
415
- create: {
416
- value: "LRS1",
417
- name: "Ladle Repair shop road 1",
418
- }
419
- },
420
- {
421
- where: {
422
- value: "LRS2",
423
- },
424
- create: {
425
- value: "LRS2",
426
- name: "Ladle Repair shop road 2",
427
- }
428
- },
429
- {
430
- where: {
431
- value: "KLO",
432
- },
433
- create: {
434
- value: "KLO",
435
- name: "Klondu",
436
- }
437
- }
438
- ]
439
- }
440
- },
441
- })
442
- const createRM = await prisma.station.create({
443
- data:
444
- {
445
- value: "R+M/BREAK",
446
- name: "R+M / Break",
447
- locations: {
448
- connectOrCreate: [
449
- {
450
- where: {
451
- value: "LRS1",
452
- },
453
- create: {
454
- value: "LRS1",
455
- name: "Ladle Repair shop road 1",
456
- }
457
- },
458
- {
459
- where: {
460
- value: "LRS2",
461
- },
462
- create: {
463
- value: "LRS2",
464
- name: "Ladle Repair shop road 2",
465
- }
466
- },
467
- ]
468
- }
469
- }
470
- });
486
+ const torpedoIdList = await prisma.torpedo.findMany({
487
+ select: {
488
+ torpedoId: true,
489
+ },
490
+ });
491
+ const stationList = await prisma.station.findMany({
492
+ select: {
493
+ id: true,
494
+ locations: true,
495
+ },
496
+ orderBy: {
497
+ id: "asc",
498
+ },
499
+ });
471
500
 
472
- console.log({
473
- create21D,
474
- create5BFE,
475
- create5BFN,
476
- create5BFW,
477
- create6PIT,
478
- createDES1,
479
- createDES2,
480
- createGAS,
481
- createHolding,
482
- createOOS,
483
- createRM,
484
- createWB1,
485
- createWB1H,
486
- createWB2,
487
- createWB2H,
488
- });
501
+ const randomtorpedoList = _.sample(torpedoIdList, stationList.length * 2);
502
+ let locationsArray = [];
503
+ for (let i = 0; i < stationList.length; i++) {
504
+ console.log(i);
505
+ const location1 = await prisma.torpedoLocation.create({
506
+ data: {
507
+ stationId: stationList[i].id,
508
+ position: 0,
509
+ torpedoId: randomtorpedoList[2 * i].torpedoId,
510
+ locationId: stationList[i].locations[0].id,
511
+ },
512
+ });
513
+ locationsArray.push(location1);
514
+ const location2 = await prisma.torpedoLocation.create({
515
+ data: {
516
+ stationId: stationList[i].id,
517
+ position: 1,
518
+ torpedoId: randomtorpedoList[2 * i + 1].torpedoId,
519
+ locationId: stationList[i].locations[0].id,
520
+ },
521
+ });
522
+ locationsArray.push(location2);
523
+ }
489
524
 
490
- const torpedoIdList = await prisma.torpedo.findMany({
491
- select: {
492
- torpedoId: true,
493
- },
494
- });
495
- const stationList = await prisma.station.findMany({
496
- select: {
497
- id: true,
498
- locations: true,
499
- },
500
- orderBy: {
501
- id: "asc"
502
- }
503
- });
525
+ const remainingTorpedoes = torpedoIdList.filter(
526
+ (a) => !randomtorpedoList.some((b) => b.torpedoId === a.torpedoId),
527
+ );
528
+ for (let i: number = 0; i < remainingTorpedoes.length; i++) {
529
+ const randomLocation = await prisma.torpedoLocation.create({
530
+ data: {
531
+ stationId: 1,
532
+ position: 2 + i,
533
+ torpedoId: remainingTorpedoes[i].torpedoId,
534
+ locationId: stationList[0].locations[0].id,
535
+ },
536
+ });
537
+ locationsArray.push(randomLocation);
538
+ }
539
+ console.log(locationsArray);
540
+ }
504
541
 
505
- const randomtorpedoList = _.sample(torpedoIdList, stationList.length * 2);
506
- let locationsArray = [];
507
- for (let i = 0; i < stationList.length; i++) {
508
- console.log(i);
509
- const location1 = await prisma.torpedoLocation.create({
510
- data: {
511
- stationId: stationList[i].id,
512
- position: 0,
513
- torpedoId: randomtorpedoList[2 * i].torpedoId,
514
- locationId: stationList[i].locations[0].id,
515
- },
516
- });
517
- locationsArray.push(location1);
518
- const location2 = await prisma.torpedoLocation.create({
519
- data: {
520
- stationId: stationList[i].id,
521
- position: 1,
522
- torpedoId: randomtorpedoList[2 * i + 1].torpedoId,
523
- locationId: stationList[i].locations[0].id,
524
- },
525
- });
526
- locationsArray.push(location2);
527
- }
542
+ // SEED: TorpedoState
543
+ if ((await prisma.torpedoState.count()) > 0) {
544
+ console.log("SEED: TorpedoState - skipped.");
545
+ } else {
546
+ console.log("SEED: TorpedoState - generating...");
528
547
 
529
- const remainingTorpedoes = torpedoIdList.filter((a) => !randomtorpedoList.some((b) => b.torpedoId === a.torpedoId));
530
- for (let i: number = 0; i < remainingTorpedoes.length; i++) {
531
- const randomLocation = await prisma.torpedoLocation.create({
532
- data: {
533
- stationId: 1,
534
- position: 2 + i,
535
- torpedoId: remainingTorpedoes[i].torpedoId,
536
- locationId: stationList[0].locations[0].id
537
- },
538
- });
539
- locationsArray.push(randomLocation);
540
- }
541
- console.log(locationsArray);
542
- }
548
+ const createTorpedoState = await prisma.torpedoState.createMany({
549
+ data: [
550
+ { name: "OPR", label: "Operational", description: "Carrying metal" },
551
+ {
552
+ name: "AVE",
553
+ label: "Available & Empty",
554
+ description: "Empty & not in Gas, OOS, LRS",
555
+ },
556
+ { name: "SBY", label: "On Gas", description: "Stand by" },
557
+ {
558
+ name: "RM",
559
+ label: "Routine Maintenance",
560
+ description: "R+M/Break for R+M",
561
+ },
562
+ {
563
+ name: "BR",
564
+ label: "Breakdown",
565
+ description: "R+M/Break for Breakdown",
566
+ },
567
+ { name: "OOS", label: "Out of service", description: "Out of service" },
568
+ ],
569
+ });
543
570
 
544
- // SEED: TorpedoState
545
- if (await prisma.torpedoState.count() > 0) {
546
- console.log("SEED: TorpedoState - skipped.");
547
- } else {
548
- console.log("SEED: TorpedoState - generating...");
571
+ console.log({
572
+ createTorpedoState,
573
+ });
574
+ }
549
575
 
550
- const createTorpedoState = await prisma.torpedoState.createMany({
551
- data: [
552
- { name: "OPR", label: "Operational", description: "Carrying metal" },
553
- { name: "AVE", label: "Available & Empty", description: "Empty & not in Gas, OOS, LRS" },
554
- { name: "SBY", label: "On Gas", description: "Stand by", },
555
- { name: "RM", label: "Routine Maintenance", description: "R+M/Break for R+M" },
556
- { name: "BR", label: "Breakdown", description: "R+M/Break for Breakdown" },
557
- { name: "OOS", label: "Out of service", description: "Out of service" },
558
- ],
559
- });
576
+ // SEED: Pot
577
+ if ((await prisma.pot.count()) > 0) {
578
+ console.log("SEED: Pot - skipped.");
579
+ } else {
580
+ console.log("SEED: Pot - generating...");
560
581
 
561
- console.log({
562
- createTorpedoState,
563
- });
564
- }
582
+ const createPot = await prisma.pot.createMany({
583
+ data: [
584
+ { name: "Pot 1" },
585
+ { name: "Pot 2" },
586
+ { name: "Pot 3" },
587
+ { name: "Pot 4" },
588
+ { name: "Pot 5" },
589
+ { name: "Pot 6" },
590
+ { name: "Pot 7" },
591
+ ],
592
+ });
565
593
 
566
- // SEED: Pot
567
- if (await prisma.pot.count() > 0) {
568
- console.log("SEED: Pot - skipped.");
569
- } else {
570
- console.log("SEED: Pot - generating...");
594
+ console.log({
595
+ createPot,
596
+ });
597
+ }
571
598
 
572
- const createPot = await prisma.pot.createMany({
573
- data: [
574
- { name: "Pot 1"},
575
- { name: "Pot 2"},
576
- { name: "Pot 3"},
577
- { name: "Pot 4"},
578
- { name: "Pot 5"},
579
- { name: "Pot 6"},
580
- { name: "Pot 7"},
581
- ],
582
- });
599
+ // SEED: OperationalState
600
+ if ((await prisma.operationalState.count()) > 0) {
601
+ console.log("SEED: OperationalState - skipped.");
602
+ } else {
603
+ console.log("SEED: OperationalState - generating...");
583
604
 
584
- console.log({
585
- createPot,
586
- });
587
- }
605
+ const createOperationalState = await prisma.operationalState.create({
606
+ data: {},
607
+ });
588
608
 
589
- // SEED: OperationalState
590
- if (await prisma.operationalState.count() > 0) {
591
- console.log("SEED: OperationalState - skipped.");
592
- } else {
593
- console.log("SEED: OperationalState - generating...");
609
+ console.log({
610
+ createOperationalState,
611
+ });
612
+ }
594
613
 
595
- const createOperationalState = await prisma.operationalState.create({ data: {} });
614
+ // SEED: NotificationCategory
615
+ if ((await prisma.notificationCategory.count()) > 0) {
616
+ console.log("SEED: NotificationCategory - skipped.");
617
+ } else {
618
+ console.log("SEED: NotificationCategory = generating...");
596
619
 
597
- console.log({
598
- createOperationalState,
599
- });
600
- }
620
+ const createNotificationCategory =
621
+ await prisma.notificationCategory.createMany({
622
+ data: [
623
+ { name: "BLAST_FURNACE", label: "Blast Furnace" },
624
+ { name: "CAST", label: "Cast" },
625
+ { name: "LIMS", label: "LIMS" },
626
+ { name: "LIMS_DESULPH", label: "Desulphurisation" },
627
+ { name: "LIMS_RUNNER", label: "Runner" },
628
+ { name: "6_PIT", label: "6-Pit" },
629
+ { name: "HOTMETAL_LEVEL", label: "Hot Metal Level" },
630
+ { name: "HMH", label: "HMH"},
631
+ { name: "TORPEDO", label: "Torpedo" },
632
+ { name: "TORPEDO_DUMPED", label: "Dumped" },
633
+ { name: "TORPEDO_EMPTY", label: "Empty" },
634
+ { name: "TORPEDO_FILL", label: "Fill" },
635
+ { name: "TORPEDO_MANUAL", label: "Manual" },
636
+ { name: "TORPEDO_MOVEMENT", label: "Movement" },
637
+ { name: "BOS", label: "BOS" },
638
+ { name: "TORPEDO_POUR", label: "Pour" },
639
+ { name: "HOTMETAL_RETURNED", label: "Returned Steel" },
640
+ { name: "POT", label: "Pot" },
641
+ { name: "CONDITION", label: "Condition" },
642
+ { name: "OVERRIDDEN", label: "Overridden" },
643
+ ],
644
+ });
645
+
646
+ console.log({
647
+ createNotificationCategory,
648
+ });
649
+ }
650
+
651
+ // SEED: NotificationDisplay
652
+ if ((await prisma.displayMode.count()) > 0) {
653
+ console.log("SEED: DisplayMode - skipped.");
654
+ } else {
655
+ console.log("SEED: DisplayMode - generating...");
656
+
657
+ const createDisplayMode = await prisma.displayMode.createMany({
658
+ data: [
659
+ {
660
+ name: "BELL",
661
+ label: "Bell",
662
+ description: "Appears within the critical alerts list.",
663
+ },
664
+ {
665
+ name: "PAGE",
666
+ label: "Page",
667
+ description:
668
+ "Appears on Notifications page, with categories for filtering.",
669
+ },
670
+ {
671
+ name: "POPUP",
672
+ label: "Popup",
673
+ description: "Appears as modal dialog, requires user interaction.",
674
+ },
675
+ {
676
+ name: "SNACKBAR",
677
+ label: "Snackbar",
678
+ description: "Appears as snackbar, visible for 5 seconds.",
679
+ },
680
+ ],
681
+ });
682
+
683
+ console.log({
684
+ createDisplayMode,
685
+ });
686
+ }
687
+
688
+ // SEED: NotificationSource
689
+ if ((await prisma.notificationSource.count()) > 0) {
690
+ console.log("SEED: NotificationSource - skipped.");
691
+ } else {
692
+ console.log("SEED: NotificationSource - generating...");
693
+
694
+ const createNotificationSource = await prisma.notificationSource.createMany(
695
+ {
696
+ data: [
697
+ { name: "BF5", label: "Blast Furnace 5 Events (Default)" },
698
+ { name: "BOS", label: "BOS Events (Default)" },
699
+ {
700
+ name: "LIMS_D",
701
+ label: "LIMS Desulphurisation sample analysis (Default)",
702
+ },
703
+ { name: "LIMS_R", label: "LIMS Runner sample analysis (Default)" },
704
+ { name: "HMH", label: "HMH Events (R+M, restrictions, survey)" },
705
+ { name: "HMM", label: "Movement (Default)" },
706
+ { name: "TIMERS", label: "Timers (6-pit, Gas)" },
707
+ ],
708
+ },
709
+ );
710
+
711
+ console.log({
712
+ createNotificationSource,
713
+ });
714
+ }
601
715
  }
602
716
 
603
717
  main()
604
- .then(async () => {
605
- await prisma.$disconnect()
606
- })
607
- .catch(async (e) => {
608
- console.error(e)
609
- await prisma.$disconnect()
610
- process.exit(1)
611
- })
718
+ .then(async () => {
719
+ await prisma.$disconnect();
720
+ })
721
+ .catch(async (e) => {
722
+ console.error(e);
723
+ await prisma.$disconnect();
724
+ process.exit(1);
725
+ });