Author: sebb
Date: Sun Jun 22 13:14:58 2025
New Revision: 1926641

URL: http://svn.apache.org/viewvc?rev=1926641&view=rev
Log:
maildata_weekly no longer used

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

Modified: comdev/reporter.apache.org/trunk/scripts/mailglomper2.py
URL: 
http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/scripts/mailglomper2.py?rev=1926641&r1=1926640&r2=1926641&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/scripts/mailglomper2.py (original)
+++ comdev/reporter.apache.org/trunk/scripts/mailglomper2.py Sun Jun 22 
13:14:58 2025
@@ -10,7 +10,6 @@
 
    Updates:
    data/maildata_extended.json - output data for display
-   data/cache/maildata_weekly.json - cache of weekly email stats
 """
 import sys
 
@@ -34,9 +33,6 @@ __RAO_HOME = "../"
 
 __MAILDATA_EXTENDED = __RAO_HOME + "data/maildata_extended.json"
 
-__MAILDATA_CACHE = __RAO_HOME + "data/cache/maildata_weekly.json"
-
-
 def tsprint(s):  # print with timestamp
     msg = "%s %s" % (time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), s)
     if isinstance(s, Exception):
@@ -50,7 +46,7 @@ def tsprint(s):  # print with timestamp
 interrupted = False
 
 
-def handle(signum, frame):
+def handle(signum, _frame):
     """
     Handles signals, e.g. ^C (SIGINT) and kill (SIGTERM)
     Sets the interrupted flag on first signal (graceful shutdown)
@@ -71,14 +67,6 @@ startTime = time.time()
 # we don't need to retain history
 mls = {}
 
-try:
-    with open(__MAILDATA_CACHE, "r") as f:
-        mldcache = json.loads(f.read())
-    tsprint("Read maildata cache successfully")
-except:
-    tsprint("Created empty maildata cache")
-    mldcache = {}
-
 DTNOW = datetime.now()
 currentMonth = DTNOW.month
 currentYear = DTNOW.year
@@ -96,18 +84,6 @@ for i in range(0, 7):
         currentYear -= 1
     months.append(date)
 
-# Remove any stale entries
-obsolete = []  # list of keys to remove (cannot do it while iterating)
-for mld in mldcache.keys():
-    yyyymm = mld[-6:]
-    if yyyymm not in months:
-        obsolete.append(mld)
-
-for key in obsolete:
-    tsprint("Dropping obsolete cache entry: " + key)
-    del mldcache[key]
-
-
 # Get the index of mailing lists
 # Not strictly necessary to cache this, but it makes testing easier
 data = requests.get("https://lists.apache.org/api/preferences.json";).json()
@@ -208,21 +184,11 @@ async def gather_stats():
             tsprint("Creating checkpoint of JSON files")
             with open(__MAILDATA_EXTENDED, "w+") as f:
                 json.dump(mls, f, indent=1)  # sort_keys is expensive
-            with open(__MAILDATA_CACHE, "w") as f:
-                json.dump(mldcache, f, indent=1)  # sort_keys is expensive
 
     tsprint("Completed scanning, writing JSON files (%s)" % str(interrupted))
     with open(__MAILDATA_EXTENDED, "w+") as f:
         json.dump(mls, f, indent=1, sort_keys=True)
 
-    # all the possible lists and dates
-    found = [ml + "-" + date for ml in mlists for date in months]
-    obsolete = mldcache.keys() - found  # drop any left over
-    for key in obsolete:
-        tsprint("Dropping unused cache entry: " + key)
-        del mldcache[key]
-    with open(__MAILDATA_CACHE, "w") as f:
-        json.dump(mldcache, f, indent=1, sort_keys=True)
     tsprint("Dumped JSON files")
     elapsed = time.time() - startTime
     tsprint("Completed in %d seconds" % elapsed)
@@ -234,4 +200,3 @@ if __name__ == "__main__":
     except Exception as e:
         tsprint("Failed: %s" % repr(e))
         raise # ensure it alerts the mailing list
-        


Reply via email to