forked from taskcluster/taskcluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0032.yml
161 lines (159 loc) · 5.29 KB
/
0032.yml
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
version: 32
description: hooks last-fire phase 2
migrationScript: 0032-migration.sql
downgradeScript: 0032-downgrade.sql
methods:
last_fire_3_entities_load:
deprecated: true
description: See taskcluster-lib-entities
mode: read
serviceName: hooks
args: partition_key text, row_key text
returns: table (partition_key_out text, row_key_out text, value jsonb, version integer, etag uuid)
body: |-
begin
end
last_fire_3_entities_create:
deprecated: true
serviceName: hooks
description: See taskcluster-lib-entities
mode: write
args: pk text, rk text, properties jsonb, overwrite boolean, version integer
returns: uuid
body: |-
begin
end
last_fire_3_entities_remove:
deprecated: true
serviceName: hooks
description: See taskcluster-lib-entities
mode: write
args: partition_key text, row_key text
returns: table (etag uuid)
body: |-
begin
end
last_fire_3_entities_modify:
deprecated: true
serviceName: hooks
description: See taskcluster-lib-entities
mode: write
args: partition_key text, row_key text, properties jsonb, version integer, old_etag uuid
returns: table (etag uuid)
body: |-
begin
end
last_fire_3_entities_scan:
deprecated: true
description: See taskcluster-lib-entities
mode: read
serviceName: hooks
args: pk text, rk text, condition text, size integer, page integer
returns: table (partition_key text, row_key text, value jsonb, version integer, etag uuid)
body: |-
begin
end
create_last_fire:
description: |-
Create a new hook last fire. Raises UNIQUE_VIOLATION if the hook already exists.
mode: write
serviceName: hooks
args: hook_group_id_in text, hook_id_in text, fired_by_in text, task_id_in text, task_create_time_in timestamptz, result_in text, error_in text
returns: uuid
body: |-
declare
new_etag uuid := public.gen_random_uuid();
begin
insert
into hooks_last_fires (hook_group_id, hook_id, fired_by, task_id, task_create_time, result, error, etag)
values (hook_group_id_in, hook_id_in, fired_by_in, task_id_in, task_create_time_in, result_in, error_in, new_etag);
return new_etag;
end
get_last_fire:
description: |-
Get a hook last fire.
mode: read
serviceName: hooks
args: hook_group_id_in text, hook_id_in text, task_id_in text
returns: table(hook_group_id text, hook_id text, fired_by text, task_id text, task_create_time timestamptz, result text, error text, etag uuid)
body: |-
begin
return query
select
hooks_last_fires.hook_group_id,
hooks_last_fires.hook_id,
hooks_last_fires.fired_by,
hooks_last_fires.task_id,
hooks_last_fires.task_create_time,
hooks_last_fires.result,
hooks_last_fires.error,
hooks_last_fires.etag
from hooks_last_fires
where
hooks_last_fires.hook_group_id = hook_group_id_in and
hooks_last_fires.hook_id = hook_id_in and
hooks_last_fires.task_id = task_id_in;
end
get_last_fires:
description: |-
Get hooks last fires filtered by the `hook_group_id` and `hook_id` arguments,
ordered by `hook_group_id`, `hook_id`, and `worker_id`.
If the pagination arguments are both NULL, all rows are returned.
Otherwise, page_size rows are returned at offset page_offset.
mode: read
serviceName: hooks
args: hook_group_id_in text, hook_id_in text, page_size_in integer, page_offset_in integer
returns: table(hook_group_id text, hook_id text, fired_by text, task_id text, task_create_time timestamptz, result text, error text, etag uuid)
body: |-
begin
return query
select
hooks_last_fires.hook_group_id,
hooks_last_fires.hook_id,
hooks_last_fires.fired_by,
hooks_last_fires.task_id,
hooks_last_fires.task_create_time,
hooks_last_fires.result,
hooks_last_fires.error,
hooks_last_fires.etag
from hooks_last_fires
where
hooks_last_fires.hook_group_id = hook_group_id_in and
hooks_last_fires.hook_id = hook_id_in
order by hook_group_id, hook_id, task_id
limit get_page_limit(page_size_in)
offset get_page_offset(page_offset_in);
end
delete_last_fires:
description: |-
Delete last fires that match a given `hook_group_id` and `hook_id`.
mode: write
serviceName: hooks
args: hook_group_id_in text, hook_id_in text
returns: void
body: |-
begin
delete from hooks_last_fires
where
hooks_last_fires.hook_group_id = hook_group_id_in and
hooks_last_fires.hook_id = hook_id_in;
end
expire_last_fires:
description: |-
Expire last fires that are older than a year.
Returns a count of rows that have been deleted.
mode: write
serviceName: hooks
args: ''
returns: integer
body: |-
declare
count integer;
begin
delete from hooks_last_fires where hooks_last_fires.task_create_time < now() - interval '1 year';
if found then
get diagnostics count = row_count;
return count;
end if;
return 0;
end