def purgeOldReports()

in crashes.py [0:0]


def purgeOldReports(reports, fxVersion):
  # Purge obsolete reports.
  # 89.0b7 89.0 90.0.1
  totalReportsDropped = 0
  for hash in reports:
    keepRepList = list()
    origRepLen = len(reports[hash]['reportList'])
    for report in reports[hash]['reportList']:
      reportVer = ''
      try:
        reportVer = getMainVer(report['firefoxver'])
      except:
        pass
      if fxVersion == reportVer:
        keepRepList.append(report)
    totalReportsDropped += (origRepLen - len(keepRepList))
    reports[hash]['reportList'] = keepRepList

  print("Removed %d older reports." % totalReportsDropped)

  # Purge signatures that have no reports
  delSigList = list()
  for hash in reports:
    newRepList = list()
    for report in reports[hash]['reportList']:
      # "crash_date":"2021-03-22"
      dateStr = report['crashdate']
      if checkCrashAge(dateStr):
        newRepList.append(report)
    reports[hash]['reportList'] = newRepList
    if len(newRepList) == 0:
      # add this signature to our purge list
      delSigList.append(hash)

  for hash in reports:
    if len(reports[hash]['reportList']) == 0:
      if hash not in delSigList:
        delSigList.append(hash)

  # purge old signatures that no longer have reports
  # associated with them.
  for hash in delSigList:
    del reports[hash]

  print("Removed %d older signatures from our reports database." % len(delSigList))