-
Notifications
You must be signed in to change notification settings - Fork 2
/
soma_stmt_tree_keeper.go
75 lines (64 loc) · 2.06 KB
/
soma_stmt_tree_keeper.go
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package main
/*
* Statements for job state updates outside transaction
*/
const tkStmtStartJob = `
UPDATE soma.jobs
SET job_started = $2::timestamptz,
job_status = 'in_progress'
WHERE job_id = $1::uuid
AND job_started IS NULL;`
const tkStmtGetViewFromCapability = `
SELECT capability_view
FROM soma.monitoring_capabilities
WHERE capability_id = $1::uuid;`
const tkStmtGetComputedDeployments = `
SELECT scic.check_instance_id,
scic.check_instance_config_id,
scic.deployment_details
FROM soma.checks sc
JOIN soma.check_instances sci
ON sc.check_id = sci.check_id
JOIN soma.check_instance_configurations scic
ON sci.check_instance_id = scic.check_instance_id
WHERE scic.status = 'computed'
AND sc.repository_id = $1::uuid;`
const tkStmtGetPreviousDeployment = `
SELECT check_instance_config_id,
version,
status,
deployment_details
FROM soma.check_instance_configurations
WHERE status != 'computed'
AND status != 'awaiting_computation'
AND check_instance_id = $1::uuid
ORDER BY version DESC
LIMIT 1;`
const tkStmtUpdateConfigStatus = `
UPDATE soma.check_instance_configurations
SET status = $1::varchar,
next_status = $2::varchar
WHERE check_instance_config_id = $3::uuid;`
const tkStmtUpdateCheckInstance = `
UPDATE soma.check_instances
SET last_configuration_created = $1::timestamptz,
update_available = $2::boolean,
current_instance_config_id = $3::uuid
WHERE check_instance_id = $4::uuid;`
const tkStmtUpdateExistingCheckInstance = `
UPDATE soma.check_instances
SET last_configuration_created = $1::timestamptz,
update_available = $2::boolean
WHERE check_instance_id = $3::uuid;`
const tkStmtDeleteDuplicateDetails = `
DELETE FROM soma.check_instance_configurations
WHERE check_instance_config_id = $1::uuid;`
const tkStmtSetDependency = `
INSERT INTO soma.check_instance_configuration_dependencies (
blocked_instance_config_id,
blocking_instance_config_id,
unblocking_state)
SELECT $1::uuid,
$2::uuid,
$3::varchar;`
// vim: ts=4 sw=4 sts=4 noet fenc=utf-8 ffs=unix