def maintenance_report(labels, trend, active_maintenance=[], title=""): created_counts = [len(t[0]) for t in trend] resolved_counts = [len(t[1]) for t in trend] mntc_chart = maintenance_created_vs_resolved_chart(labels, created_counts, resolved_counts) content = page.embed_image(filename=mntc_chart) averages = [] stds = [] for t in trend: resolved = t[1] lead_time = [] for i in resolved: lead_time.append(i.calc_lead_time()) averages.append(int(round(np.average(lead_time), 0))) stds.append(round(np.std(lead_time), 0)) lt_chart = resolved_issues_lead_times(labels, averages, stds) content += page.embed_image(filename=lt_chart) if active_maintenance: content += page.format_text( "p", f"Active maintenance: {len(active_maintenance)}") content += page.embed_expand_macro( page.embed_jira_macro( f'issuekey in ({", ".join(active_maintenance)})'), "Maintenance backlog", ) return content, [mntc_chart, lt_chart]
def internal_vs_external_dependencies( jira_access, projects_list, metrics, title="Internal vs external dependencies"): attachments = [] dm_all_with_dep = [ ticket.get_issue_by_key(jira_access, issue_key) for issue_key in metrics.latest["all_with_dep"] ] inter_extern_stats = dep.count_internal(dm_all_with_dep, projects_list) chart_file = inter_extern_stats_pie_chart(inter_extern_stats, title) attachments.append(chart_file) content = page.embed_image(filename=chart_file) issues_with_internal_dep = inter_extern_stats["internal"] issues_with_external_dep = inter_extern_stats["external"] content += page.embed_expand_macro( page.embed_jira_macro( f'issuekey in ({", ".join(issues_with_internal_dep)})'), "Issues with internal dependencies", ) content += page.embed_expand_macro( page.embed_jira_macro( f'issuekey in ({", ".join(issues_with_external_dep)})'), "Issues with external dependencies", ) return content, attachments
def dependency_report(independence, all_issues, all_with_dep, metrics_history=None): content = page.format_text( "h3", f"Independence factor = {round(independence)}% ") attachments = [] if metrics_history: chart_file = metrics_history_chart(metrics_history) attachments.append(chart_file) content += page.embed_image(filename=chart_file) if len(all_with_dep): # dependency charts content += page.format_text("h2", "External dependency split") count_stats = dep.count_stats(all_with_dep) stats_list = [i for i in count_stats if len(i) > 0] att = [] att.append( stats_pie_charts( stats_list, title=None, sub_titles=("By team", "By Epic", "By external epic"), )) content += page.embed_images(filename_list=att) attachments += att # dependency graphs dependency_content, dependency_graphs = dependency_analysis( all_with_dep) content += dependency_content attachments += dependency_graphs return content, attachments
def execution_report(projetcs_progress): labels = [] progress = [] all_stories_count = 0 done_stories_count = 0 for project_key, sprint_progress in projetcs_progress.items(): labels.append(project_key) p = round(sprint_progress[0]) all_stories_count += len(sprint_progress[1]) done_stories_count += len(sprint_progress[2]) progress.append(p) labels.append("Total") progress.append( round(done_stories_count * 100 / all_stories_count, 0) if all_stories_count else 0) plt = charts.barh_progress(labels, progress, None, "Execution summary", invert_labels=False) barh_chart_filename = f"execution summary {id(progress)}.png" plt.savefig(barh_chart_filename) plt.close() content = page.embed_image(filename=barh_chart_filename) return content, [barh_chart_filename]
def dependency_analysis(issues_with_dep): attachments = [] content = "" if len(issues_with_dep): page_content = "" for issue_cache in issues_with_dep: graph_filename = dependency_graph(issue_cache) attachments.append(graph_filename) page_content += page.embed_image(graph_filename) deps = [*issue_cache.linked_issues] deps.append(issue_cache.key) page_content += page.embed_jira_macro( f'issuekey in ({", ".join(deps)})') page_content += "<hr />" content += ( page_content # page.embed_expand_macro(page_content, "Dependency graphs") ) return content, attachments
def history_execution_report(history): barh_chart_filename = execution_progress_chart(history) content = page.embed_image(filename=barh_chart_filename) last_sprint_key = next(reversed(history.keys())) last_sprint = history[last_sprint_key].sprint goal = last_sprint.goal if hasattr(last_sprint, "goal") else "" if last_sprint.state == "active": content += page.format_text("p", f'Active sprint: "{last_sprint.name}"') content += page.format_text("p", f'The goal of the active sprint: "{goal}"') else: content += page.format_text( "p", f'No sprint is active. Last sprint: "{last_sprint.name}"' ) content += page.format_text("p", f'The goal of the last sprint: "{goal}"') content += page.format_text( "p", f'Start: {last_sprint.startDate.split("T")[0]}, End: {last_sprint.endDate.split("T")[0]}', ) return content, [barh_chart_filename]
def dependency_summary(jira_access, metrics_history, project_list): new_content = "" attachments = [] table = {"Squad": [], "Factor": [], "Date": [], "Trend": []} for k, v in metrics_history.items(): table["Squad"].append( page.format_link(f"{k} - Dependencies after refinement", k)) table["Factor"].append(f'{round(v.latest["independence"])}%') table["Date"].append( datetime.datetime.fromtimestamp(v.latest["timestamp"]).date()) trend = v.trend trend_arrow = page.rightwards_arrow() if trend > 0: trend_arrow = page.upwards_arrow() elif trend < 0: trend_arrow = page.downwards_arrow() table["Trend"].append(trend_arrow) total_m = metrics_store.merge(metrics_history.values()) new_content += page.format_text( "h3", f'Total factor = {total_m.latest["independence"]}% ') chart_file = metrics_history_chart(total_m) attachments.append(chart_file) new_content += page.embed_image(filename=chart_file) if jira_access is not None: more_analysis_content, more_att = internal_vs_external_dependencies( jira_access, project_list, total_m) new_content += page.embed_expand_macro(more_analysis_content, "More analysis...") attachments += more_att new_content += page.format_table(table) return new_content, attachments
def sprint_churn_report(labels, added, removed, unblocked, blocked): chart_filename = sprint_churn_chart(labels, added, removed, unblocked, blocked) content = page.embed_image(filename=chart_filename) return content, [chart_filename]