From c4850c8cfb8973502c3263d063415fec12d78bc9 Mon Sep 17 00:00:00 2001
From: Thomas Kluyver <thomas@kluyver.me.uk>
Date: Mon, 13 Feb 2023 15:10:09 +0000
Subject: [PATCH] Replace 'R' status for correction with 'IP'

---
 webservice/job_monitor.py | 7 +++----
 webservice/webservice.py  | 6 +++---
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/webservice/job_monitor.py b/webservice/job_monitor.py
index 037575d8e..d0662a203 100644
--- a/webservice/job_monitor.py
+++ b/webservice/job_monitor.py
@@ -285,12 +285,11 @@ class JobsMonitor:
             status = 'F' if success else 'E'  # Finished/Error
             self.mymdc_update_dark(r['mymdc_id'], msg, status)
 
-    def mymdc_update_run(self, run_id, msg, status='R'):
+    def mymdc_update_run(self, run_id, msg, status='IP'):
         """Update correction status in MyMdC"""
-        data = {'cal_pipeline_reply': msg}
-        if status != 'R':
+        data = {'cal_pipeline_reply': msg, 'flg_cal_data_status': status}
+        if status != 'IP':
             data['cal_last_end_at'] = datetime.now(tz=timezone.utc).isoformat()
-            data['flg_cal_data_status'] = status
         response = self.mdc.update_run_api(run_id, data)
         if response.status_code != 200:
             log.error("Failed to update MDC run id %s", run_id)
diff --git a/webservice/webservice.py b/webservice/webservice.py
index 25c3d1fe6..dda291c2e 100644
--- a/webservice/webservice.py
+++ b/webservice/webservice.py
@@ -744,7 +744,7 @@ async def update_mdc_status(mdc: MetadataClient, action: str,
     if message.split(':')[0] in ('FAILED', 'WARN'):  # Errors
         flag = 'E'
     elif message.split(':')[0] == 'SUCCESS':  # Success
-        flag = 'R' if action == 'correct' else 'IP'
+        flag = 'IP'
         if 'Uploaded' in message or 'Finished' in message:
             flag = 'A' if action == 'correct' else 'F'
     else:  # MDC Timeout
@@ -753,8 +753,8 @@ async def update_mdc_status(mdc: MetadataClient, action: str,
     if action == 'correct':
         func = mdc.update_run_api
         data = {'cal_pipeline_reply': message}
-        # Don't send the 'R' status, as this may trigger another correction
-        if flag != 'R':
+        # Don't send In Progress; job_monitor will send this when jobs start.
+        if flag != 'IP':
             data['flg_cal_data_status'] = flag
 
     elif action == 'dark_request':
-- 
GitLab