da = DataAnalysis(config['database-url']) for repo in config['repos']: page_title = repo.get('title', '').format(date=datetime.datetime.now()) hash_id = hashlib.md5(repo['path']).hexdigest() data = [] for chart in config['charts']: num_days = chart['duration'] d = [] if chart['data-type'] == 'average': # Compute averages for branch in repo['highlight-branches']: d.append(da.compute_averages(hash_id, num_days, ['success'], branch, weekdays_only)) d.append(da.compute_averages(hash_id, num_days, ['success'], None, weekdays_only)) d = da.pad_missing_days(d) data.append({ "label" : chart['label'], "id" : hashlib.md5(chart['label']).hexdigest(), "chart_type" : chart['chart-type'], "data_type" : chart['data-type'], 'data' : d, "colors" : chart.get('colors', None) }) elif chart['data-type'] == 'top-builds': d.append(da.compute_top_builders(hash_id, num_days,
weekdays_only = config['weekdays-only'] def display(data): pre = data.branch if pre is None: pre = '' days = sorted(data.data.keys()) for i in days: print("{0}>{1}:{2}".format(pre, i,data.data[i])) #print("{0}-----{1}".format(pre, data.average)) print("{0}-----{1}".format(pre, len(data.data))) for repo in config['repos']: hash_id = hashlib.md5(repo['path']).hexdigest() for chart in config['charts']: print(chart['label']) num_days = chart['duration'] d = [] if chart['data-type'] == 'average': d.append(da.compute_averages(hash_id, num_days, outcomes, None, weekdays_only)) for branch in repo['highlight-branches']: d.append(da.compute_averages(hash_id, num_days, outcomes, branch, weekdays_only)) d = da.pad_missing_days(d) for i in d: display(i) print("max_days: {0}\tweekdays_only: {1}\n".format(num_days, weekdays_only))