-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_admin.cjs
More file actions
46 lines (40 loc) · 1.93 KB
/
Copy pathfix_admin.cjs
File metadata and controls
46 lines (40 loc) · 1.93 KB
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
const fs = require('fs');
const path = 'backend/src/routes/admin.ts';
let code = fs.readFileSync(path, 'utf8');
const searchStr = ` occupancy_pct,
headline: concerns.length > 0
? \`\${concerns.length} high-density zone\${concerns.length === 1 ? '' : 's'} require attention.\`
: \`Operations stable during \${sim.phase().replace('_', ' ')}.\`,
summary:`;
const replaceStr = ` occupancy_pct,
headline: concerns.length > 0
? \`\${concerns.length} high-density zone\${concerns.length === 1 ? '' : 's'} require attention.\`
: \`Operations stable during \${sim.phase().replace('_', ' ')}.\`,
summary:`;
// Actually let's just make a variable `zoneSuffix` before the return statement.
const searchBlock = ` const now = new Date();
return BriefingSchema.parse({
id: \`brf_\${randomUUID().slice(0, 8)}\`,
venue_id,
generated_at: now.toISOString(),
window_start: now.toISOString(),
window_end: new Date(now.getTime() + 300_000).toISOString(),
occupancy_pct,
headline: concerns.length > 0
? \`\${concerns.length} high-density zone\${concerns.length === 1 ? '' : 's'} require attention.\`
: \`Operations stable during \${sim.phase().replace('_', ' ')}.\`,`;
const replaceBlock = ` const now = new Date();
const zoneSuffix = concerns.length === 1 ? '' : 's';
const headlineText = concerns.length > 0
? \`\${concerns.length} high-density zone\${zoneSuffix} require attention.\`
: \`Operations stable during \${sim.phase().replace('_', ' ')}.\`;
return BriefingSchema.parse({
id: \`brf_\${randomUUID().slice(0, 8)}\`,
venue_id,
generated_at: now.toISOString(),
window_start: now.toISOString(),
window_end: new Date(now.getTime() + 300_000).toISOString(),
occupancy_pct,
headline: headlineText,`;
code = code.replace(searchBlock, replaceBlock);
fs.writeFileSync(path, code);