Author: sebb
Date: Sat Aug  9 13:00:12 2025
New Revision: 1927714

Log:
Remove retired JSON files (no point maintaining them)

Modified:
   comdev/reporter.apache.org/trunk/scripts/readjira.py

Modified: comdev/reporter.apache.org/trunk/scripts/readjira.py
==============================================================================
--- comdev/reporter.apache.org/trunk/scripts/readjira.py        Sat Aug  9 
12:28:16 2025        (r1927713)
+++ comdev/reporter.apache.org/trunk/scripts/readjira.py        Sat Aug  9 
13:00:12 2025        (r1927714)
@@ -71,21 +71,34 @@ def logout():
     res = requests.delete(JIRA_AUTH, headers=hdrs, timeout=JIRATIMEOUT)
     res.raise_for_status()
 
+def getJsonPath(project):
+    return f"{MYHOME}/data/JIRA/{project}.json"
+
 def getProjects():
     """Update the list of projects in data/JIRA/jira_projects.json"""
     print(f"Refresh {PROJECT_JSON}")
     try:
         res = requests.get(JIRA_PROJ, headers=hdrs, timeout=JIRATIMEOUT)
         res.raise_for_status()
+        jzon = res.json()
         with open(PROJECT_JSON, "w") as f:
-            json.dump(res.json(), f, indent=1, sort_keys=True)
+            json.dump(jzon, f, indent=1, sort_keys=True)
         print(f"Created {PROJECT_JSON}")
+        # Remove retired entries
+        for entry in jzon:
+            cat = entry.get('projectCategory','')
+            if cat and cat['name'] == 'Retired':
+                project = entry['key']
+                file = getJsonPath(project)
+                if isfile(file):
+                    print(f"Retired project: {project}, removing {file}")
+                    os.remove(file)
     except Exception as e:
         print(f"Err: could not refresh {PROJECT_JSON}: {e}")
         sys.exit("Failed to update project list - quitting. See 
/var/log/www-data/readjira.log for details.")
 
 def getJIRAS(project):
-    file = f"{MYHOME}/data/JIRA/{project}.json"
+    file = getJsonPath(project)
     created =  JIRA_QURY % (project, 'created')
     resolved = JIRA_QURY % (project, 'resolved')
     res = None

Reply via email to