From 4515649f1308fc0257bc5bfc014250e47e35ea50 Mon Sep 17 00:00:00 2001 From: Kumaresh-Krishnan Date: Wed, 22 Jun 2016 08:41:21 -0400 Subject: [PATCH 1/2] Added generation of csv style report saved to media/tmp/ --- src/openbadge/newGraph.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/openbadge/newGraph.py b/src/openbadge/newGraph.py index 0ae2ec3..341b20a 100644 --- a/src/openbadge/newGraph.py +++ b/src/openbadge/newGraph.py @@ -1,7 +1,7 @@ from matplotlib import pyplot, dates, rcParams from django.conf import settings -import os +import os, csv def groupStatGraph(durations, num_meetings, days, names, graph_path): @@ -44,8 +44,11 @@ def groupStatGraph(durations, num_meetings, days, names, graph_path): agg_graph_file = aggregateGraph(agg_duration, agg_num_meetings, days, graph_path) + generateTable(durations, days, names, graph_path) + return {'group_img':'team_meeting_summary_graph.png', 'agg_img':agg_graph_file, - 'time':{'hrs':int(total_time), 'mins': int((total_time-int(total_time))*60)}, 'num_meetings':sum(agg_num_meetings)} + 'time':{'hrs':int(total_time), 'mins': int((total_time-int(total_time))*60)}, + 'num_meetings':sum(agg_num_meetings)} def aggregateGraph(durations, num_meetings, days, graph_path): @@ -67,4 +70,20 @@ def aggregateGraph(durations, num_meetings, days, graph_path): pyplot.close() return 'aggregate_summary_graph.png' + +def generateTable(durations, days, names, table_path): + + headers = days + headers.insert(0, 'Group\Date') + + csv_data = durations + + for i in xrange(len(names)): + csv_data[i].insert(0, names[i]) + csv_data.insert(0, headers) + + table_stats = csv.writer(open(table_path + '/group_stats.csv', 'wb')) + table_stats.writerows(csv_data) + + return From 1622648585fd491fb7162778bbfd6d7a713c0618 Mon Sep 17 00:00:00 2001 From: Kumaresh-Krishnan Date: Wed, 22 Jun 2016 11:09:50 -0400 Subject: [PATCH 2/2] Added link to the csv file in internal report webpage --- src/openbadge/newGraph.py | 6 +++--- src/openbadge/templates/reports/internal_report.html | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/openbadge/newGraph.py b/src/openbadge/newGraph.py index 341b20a..3f56b66 100644 --- a/src/openbadge/newGraph.py +++ b/src/openbadge/newGraph.py @@ -44,11 +44,11 @@ def groupStatGraph(durations, num_meetings, days, names, graph_path): agg_graph_file = aggregateGraph(agg_duration, agg_num_meetings, days, graph_path) - generateTable(durations, days, names, graph_path) + csv_file = generateTable(durations, days, names, graph_path) return {'group_img':'team_meeting_summary_graph.png', 'agg_img':agg_graph_file, 'time':{'hrs':int(total_time), 'mins': int((total_time-int(total_time))*60)}, - 'num_meetings':sum(agg_num_meetings)} + 'num_meetings':sum(agg_num_meetings), 'stats_csv':csv_file} def aggregateGraph(durations, num_meetings, days, graph_path): @@ -86,4 +86,4 @@ def generateTable(durations, days, names, table_path): table_stats = csv.writer(open(table_path + '/group_stats.csv', 'wb')) table_stats.writerows(csv_data) - return + return 'group_stats.csv' diff --git a/src/openbadge/templates/reports/internal_report.html b/src/openbadge/templates/reports/internal_report.html index 0361cec..e056e2b 100644 --- a/src/openbadge/templates/reports/internal_report.html +++ b/src/openbadge/templates/reports/internal_report.html @@ -52,7 +52,7 @@

Aggregate Meetings And Duration For Each Day

graph
-
Bar graph denotes number of meetings and line denotes duration
+

Link to CSV file for group statistics