yocto-autobuilder-helper/scripts/patchmetrics-generate-chartdata
hulkoba de094db1bb generate-chartdata: do not create lastyear json files
the two html files, index.html and index-full.html,
got merged so we only need the json file with the complete set of data.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2024-04-25 14:43:55 +01:00

1.5 KiB
Executable File

#!/usr/bin/env python3 import json, os.path, collections import sys import argparse import subprocess import tempfile from datetime import datetime, date, timedelta

args = argparse.ArgumentParser(description="Generate Patch Metric Chart data file") args.add_argument("-j", "--json", help="JSON data file to use") args.add_argument("-o", "--outputdir", help="output directory") args = args.parse_args()

status_values = ["accepted", "pending", "inappropriate", "backport", "submitted", "denied", "inactive-upstream", "malformed-upstream-status", "malformed-sob"]

data = json.load(open(args.json))

Write the latest patch breakdown to a file for the pie chart

latest = {'date' : "0"} for i in data: if int(i['date']) > int(latest['date']): latest = i json.dump(latest, open(args.outputdir + "/patch-status-pie.json", "w"), sort_keys=True, indent="\t")

Write patch counts by day

def round_to_day(val): return int((datetime.fromtimestamp(int(val)).date() - date(1970, 1, 1)).total_seconds())

newdata = [] databydate = {} for i in data: rounded = round_to_day(i['date']) if rounded not in databydate: databydate[rounded] = i elif rounded in databydate and databydate[rounded]['date'] < i['date']: databydate[rounded] = i

for i in databydate: for todel in ['commit', 'commit_count']: if todel in databydate[i]: del databydate[i][todel] newdata.append(databydate[i])

json.dump(newdata, open(args.outputdir + "/patch-status-byday.json", "w"), sort_keys=True, indent="\t")