-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.ts
58 lines (48 loc) · 1.92 KB
/
index.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
import { downloadFile, waitForFreshData } from './steps/download'
import {
clearCache,
restartTileServer,
triggerCacheWarming,
triggerPostProcessing,
} from './steps/externalTriggers'
import { idFilter, tagFilter } from './steps/filter'
import { generateTypes } from './steps/generateTypes'
import { initialize } from './steps/initialize'
import { writeMetadata } from './steps/metadata'
import { processTopics } from './steps/processTopics'
import { logPadded, logTileInfo } from './utils/logging'
import { params } from './utils/parameters'
import { synologyLogError } from './utils/synology'
async function main() {
try {
logPadded('Processing')
console.log('Processing:', 'Initilize')
await initialize()
console.log('Processing:', 'Handle Data')
await waitForFreshData()
let { fileName, fileChanged } = await downloadFile()
console.log('Processing:', 'Handle Filter')
await tagFilter(fileName, fileChanged)
const idFilterResponse = await idFilter(fileName, params.idFilter)
if (idFilterResponse) ({ fileName, fileChanged } = idFilterResponse)
console.log('Processing:', 'Handle Topics')
const { timeElapsed, processedTables } = await processTopics(fileName, fileChanged)
await generateTypes(processedTables)
await writeMetadata(fileName, timeElapsed)
console.log('Processing:', 'Finishing up')
// Call the frontend update hook which registers sql functions and starts the analysis run
await triggerPostProcessing()
// Restart `tiles` container to refresh `/catalog`
await restartTileServer()
// Handle cache warming hook
await clearCache()
if (!params.skipWarmCache) {
await triggerCacheWarming()
}
logTileInfo()
} catch (error) {
// This `catch` will only trigger if child functions are `await`ed AND file calls a `main()` function. Top level code does not work.
synologyLogError(`Processing failed: ${error}`)
}
}
main()