mirror of
git://git.yoctoproject.org/yocto-autobuilder-helper.git
synced 2025-07-19 20:59:02 +02:00
scripts/generate-charts: Add json data for last year as well as multiyear
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
fe0d12175f
commit
01f4920d78
|
@ -5,6 +5,7 @@ import argparse
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
from datetime import datetime, date
|
from datetime import datetime, date
|
||||||
|
from dateutil.relativedelta import relativedelta
|
||||||
|
|
||||||
args = argparse.ArgumentParser(description="Generate CVE count data files")
|
args = argparse.ArgumentParser(description="Generate CVE count data files")
|
||||||
args.add_argument("-j", "--json", help="JSON data file to use")
|
args.add_argument("-j", "--json", help="JSON data file to use")
|
||||||
|
@ -14,12 +15,16 @@ args = args.parse_args()
|
||||||
with open(args.json) as f:
|
with open(args.json) as f:
|
||||||
counts = json.load(f)
|
counts = json.load(f)
|
||||||
|
|
||||||
|
lastyear = {}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Write CVE counts by day
|
# Write CVE counts by day
|
||||||
#
|
#
|
||||||
def round_to_day(val):
|
def round_to_day(val):
|
||||||
return int((datetime.fromtimestamp(int(val)).date() - date(1970, 1, 1)).total_seconds())
|
return int((datetime.fromtimestamp(int(val)).date() - date(1970, 1, 1)).total_seconds())
|
||||||
|
|
||||||
|
a_year_ago = (datetime.now() - relativedelta(years=1) - datetime(1970, 1, 1)).total_seconds()
|
||||||
|
|
||||||
for branch in os.listdir(args.resultsdir):
|
for branch in os.listdir(args.resultsdir):
|
||||||
branchdir = os.path.join(args.resultsdir, branch)
|
branchdir = os.path.join(args.resultsdir, branch)
|
||||||
for f in os.listdir(branchdir):
|
for f in os.listdir(branchdir):
|
||||||
|
@ -43,8 +48,15 @@ for branch in os.listdir(args.resultsdir):
|
||||||
print("Adding count %s for branch %s from file %s (ts %s)" % (count, branch, cvereport, rounded_ts))
|
print("Adding count %s for branch %s from file %s (ts %s)" % (count, branch, cvereport, rounded_ts))
|
||||||
counts[rounded_ts][branch] = str(count)
|
counts[rounded_ts][branch] = str(count)
|
||||||
|
|
||||||
|
for c in counts:
|
||||||
|
if int(c) > a_year_ago:
|
||||||
|
lastyear[c] = counts[c]
|
||||||
|
|
||||||
with open(args.json, "w") as f:
|
with open(args.json, "w") as f:
|
||||||
json.dump(counts, f, sort_keys=True, indent="\t")
|
json.dump(counts, f, sort_keys=True, indent="\t")
|
||||||
|
|
||||||
|
with open(args.json.replace(".json", "-lastyear.json") , "w") as f:
|
||||||
|
json.dump(lastyear, f, sort_keys=True, indent="\t")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import argparse
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
from datetime import datetime, date
|
from datetime import datetime, date
|
||||||
|
from dateutil.relativedelta import relativedelta
|
||||||
|
|
||||||
args = argparse.ArgumentParser(description="Generate Patch Metric Chart data files")
|
args = argparse.ArgumentParser(description="Generate Patch Metric Chart data files")
|
||||||
args.add_argument("-j", "--json", help="JSON data file to use")
|
args.add_argument("-j", "--json", help="JSON data file to use")
|
||||||
|
@ -31,7 +31,10 @@ json.dump(latest, open(args.outputdir + "/patch-status-pie.json", "w"), sort_key
|
||||||
def round_to_day(val):
|
def round_to_day(val):
|
||||||
return int((datetime.fromtimestamp(int(val)).date() - date(1970, 1, 1)).total_seconds())
|
return int((datetime.fromtimestamp(int(val)).date() - date(1970, 1, 1)).total_seconds())
|
||||||
|
|
||||||
|
a_year_ago = (datetime.now() - relativedelta(years=1) - datetime(1970, 1, 1)).total_seconds()
|
||||||
|
|
||||||
newdata = []
|
newdata = []
|
||||||
|
lastyeardata = []
|
||||||
databydate = {}
|
databydate = {}
|
||||||
for i in data:
|
for i in data:
|
||||||
rounded = round_to_day(i['date'])
|
rounded = round_to_day(i['date'])
|
||||||
|
@ -45,6 +48,8 @@ for i in databydate:
|
||||||
if todel in databydate[i]:
|
if todel in databydate[i]:
|
||||||
del databydate[i][todel]
|
del databydate[i][todel]
|
||||||
newdata.append(databydate[i])
|
newdata.append(databydate[i])
|
||||||
|
if int(databydate[i]['date']) > a_year_ago:
|
||||||
|
lastyeardata.append(databydate[i])
|
||||||
|
|
||||||
json.dump(newdata, open(args.outputdir + "/patch-status-byday.json", "w"), sort_keys=True, indent="\t")
|
json.dump(newdata, open(args.outputdir + "/patch-status-byday.json", "w"), sort_keys=True, indent="\t")
|
||||||
|
json.dump(lastyeardata, open(args.outputdir + "/patch-status-byday-lastyear.json", "w"), sort_keys=True, indent="\t")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user