@@ -96,8 +96,8 @@ pub(crate) async fn get_pipeline_monitor_event_short(
9696 let stmt = txn
9797 . prepare_cached ( & format ! (
9898 "SELECT {RETRIEVE_SHORT_PIPELINE_EVENT_COLUMNS}
99- FROM pipeline_monitor_event AS e
100- WHERE e .tenant_id = $1 AND e.pipeline_id = $2 AND e.id = $3
99+ FROM pipeline_monitor_event AS e, pipeline AS p
100+ WHERE p .tenant_id = $1 AND p.id = e.pipeline_id AND e.pipeline_id = $2 AND e.id = $3
101101 "
102102 ) )
103103 . await ?;
@@ -122,8 +122,8 @@ pub(crate) async fn get_pipeline_monitor_event_extended(
122122 let stmt = txn
123123 . prepare_cached ( & format ! (
124124 "SELECT {RETRIEVE_EXTENDED_PIPELINE_EVENT_COLUMNS}
125- FROM pipeline_monitor_event AS e
126- WHERE e .tenant_id = $1 AND e.pipeline_id = $2 AND e.id = $3
125+ FROM pipeline_monitor_event AS e, pipeline AS p
126+ WHERE p .tenant_id = $1 AND p.id = e.pipeline_id AND e.pipeline_id = $2 AND e.id = $3
127127 "
128128 ) )
129129 . await ?;
@@ -147,8 +147,8 @@ pub(crate) async fn get_latest_pipeline_monitor_event_short(
147147 let stmt = txn
148148 . prepare_cached ( & format ! (
149149 "SELECT {RETRIEVE_SHORT_PIPELINE_EVENT_COLUMNS}
150- FROM pipeline_monitor_event AS e
151- WHERE e .tenant_id = $1 AND e.pipeline_id = $2
150+ FROM pipeline_monitor_event AS e, pipeline AS p
151+ WHERE p .tenant_id = $1 AND p.id = e.pipeline_id AND e.pipeline_id = $2
152152 ORDER BY e.recorded_at DESC, e.id DESC
153153 LIMIT 1
154154 "
@@ -174,8 +174,8 @@ pub(crate) async fn get_latest_pipeline_monitor_event_extended(
174174 let stmt = txn
175175 . prepare_cached ( & format ! (
176176 "SELECT {RETRIEVE_EXTENDED_PIPELINE_EVENT_COLUMNS}
177- FROM pipeline_monitor_event AS e
178- WHERE e .tenant_id = $1 AND e.pipeline_id = $2
177+ FROM pipeline_monitor_event AS e, pipeline AS p
178+ WHERE p .tenant_id = $1 AND p.id = e.pipeline_id AND e.pipeline_id = $2
179179 ORDER BY e.recorded_at DESC, e.id DESC
180180 LIMIT 1
181181 "
@@ -201,8 +201,8 @@ pub(crate) async fn list_pipeline_monitor_events_short(
201201 let stmt = txn
202202 . prepare_cached ( & format ! (
203203 "SELECT {RETRIEVE_SHORT_PIPELINE_EVENT_COLUMNS}
204- FROM pipeline_monitor_event AS e
205- WHERE e .tenant_id = $1 AND e.pipeline_id = $2
204+ FROM pipeline_monitor_event AS e, pipeline AS p
205+ WHERE p .tenant_id = $1 AND p.id = e.pipeline_id AND e.pipeline_id = $2
206206 ORDER BY e.recorded_at DESC, e.id DESC
207207 "
208208 ) )
@@ -229,43 +229,42 @@ pub(crate) async fn new_pipeline_monitor_event(
229229 . prepare_cached (
230230 "INSERT INTO pipeline_monitor_event
231231 (
232- id, tenant_id, pipeline_id,
232+ id, pipeline_id,
233233 resources_status, resources_status_details, resources_desired_status,
234234 runtime_status, runtime_status_details, runtime_desired_status,
235235 program_status, storage_status
236236 )
237237 VALUES
238238 (
239- $1, $2, $3,
240- $4 , $5 , $6 ,
241- $7 , $8 , $9 ,
242- $10 , $11
239+ $1, $2,
240+ $3 , $4 , $5 ,
241+ $6 , $7 , $8 ,
242+ $9 , $10
243243 )" ,
244244 )
245245 . await ?;
246246 txn. execute (
247247 & stmt,
248248 & [
249249 & new_id, // $1: id
250- & tenant_id. 0 , // $2: tenant_id
251- & pipeline_id. 0 , // $3: pipeline_id
252- & pipeline. deployment_resources_status . to_string ( ) , // $4: resources_status
250+ & pipeline_id. 0 , // $2: pipeline_id
251+ & pipeline. deployment_resources_status . to_string ( ) , // $3: resources_status
253252 & pipeline
254253 . deployment_resources_status_details
255254 . unwrap_or ( json ! ( { } ) )
256- . to_string ( ) , // $5 : resources_status_details
257- & pipeline. deployment_resources_desired_status . to_string ( ) , // $6 : resources_desired_status
255+ . to_string ( ) , // $3 : resources_status_details
256+ & pipeline. deployment_resources_desired_status . to_string ( ) , // $4 : resources_desired_status
258257 & pipeline
259258 . deployment_runtime_status
260- . map ( runtime_status_to_string) , // $7 : runtime_status
259+ . map ( runtime_status_to_string) , // $6 : runtime_status
261260 & pipeline
262261 . deployment_runtime_status_details
263- . map ( |v| v. to_string ( ) ) , // $8 : runtime_status_details
262+ . map ( |v| v. to_string ( ) ) , // $7 : runtime_status_details
264263 & pipeline
265264 . deployment_runtime_desired_status
266- . map ( runtime_desired_status_to_string) , // $9 : runtime_desired_status
267- & pipeline. program_status . to_string ( ) , // $10 : program_status
268- & pipeline. storage_status . to_string ( ) , // $11 : storage_status
265+ . map ( runtime_desired_status_to_string) , // $8 : runtime_desired_status
266+ & pipeline. program_status . to_string ( ) , // $9 : program_status
267+ & pipeline. storage_status . to_string ( ) , // $10 : storage_status
269268 ] ,
270269 )
271270 . await
@@ -278,21 +277,17 @@ pub(crate) async fn new_pipeline_monitor_event(
278277 WHERE e1.id NOT IN ( \
279278 SELECT e2.id \
280279 FROM pipeline_monitor_event AS e2 \
281- WHERE tenant_id = $1 AND pipeline_id = $2
280+ WHERE pipeline_id = $1
282281 ORDER BY e2.recorded_at DESC, e2.id DESC \
283- LIMIT $3 \
284- ) AND tenant_id = $1 AND pipeline_id = $2
282+ LIMIT $2 \
283+ ) AND pipeline_id = $1
285284 " ,
286285 )
287286 . await ?;
288287 let num_deleted_due_to_limit = txn
289288 . execute (
290289 & stmt,
291- & [
292- & tenant_id. 0 ,
293- & pipeline_id. 0 ,
294- & ( MONITOR_PIPELINE_RETENTION_NUM as i64 ) ,
295- ] ,
290+ & [ & pipeline_id. 0 , & ( MONITOR_PIPELINE_RETENTION_NUM as i64 ) ] ,
296291 )
297292 . await ?;
298293 Ok ( num_deleted_due_to_limit)
0 commit comments