Quellcode durchsuchen

1st attempt hour_of_week and commits_by_author

Schultz vor 8 Jahren
Ursprung
Commit
6ed670ca68
1 geänderte Dateien mit 31 neuen und 7 gelöschten Zeilen
  1. 31
    7
      gitstats

+ 31
- 7
gitstats Datei anzeigen

@@ -874,6 +874,7 @@ class HTMLReportCreator(ReportCreator):
874 874
                 fg.write('%d 0\n' % (i + 1))
875 875
         fg.close()
876 876
 
877
+
877 878
         # Day of Week
878 879
 
879 880
         writeHeaderstoNewTSV("FlaskTest/static/data/day_of_week_TEST.tsv", ['day_number','day_name','commits'])
@@ -882,14 +883,15 @@ class HTMLReportCreator(ReportCreator):
882 883
         f.write(html_header(2, 'Day of Week'))
883 884
         day_of_week = data.getActivityByDayOfWeek()
884 885
         f.write('<div class="vtable"><table>')
885
-        f.write('<tr><th>Day</th><th>Total (%)</th></tr>')
886
+        f.write('<tr><th>Day</th><th>Total (%)</th></tr>')cat 
886 887
         fp = open(path + '/day_of_week.dat', 'w')
887 888
         for d in range(0, 7):
888 889
             commits = 0
889 890
             if d in day_of_week:
890 891
                 commits = day_of_week[d]
891 892
             fp.write('%d %s %d\n' % (d + 1, WEEKDAYS[d], commits))
892
-            day_of_week_tsv.write("%d\t%s\t%d\n" %(d, WEEKDAYS[d],commits))
893
+            # WRITE TO TSV, add +1, may cause off by one err
894
+            day_of_week_tsv.write("%d\t%s\t%d\n" %(d+1, WEEKDAYS[d],commits))
893 895
             f.write('<tr>')
894 896
             f.write('<th>%s</th>' % (WEEKDAYS[d]))
895 897
             if d in day_of_week:
@@ -902,10 +904,10 @@ class HTMLReportCreator(ReportCreator):
902 904
         fp.close()
903 905
 
904 906
        
905
-        writeHeaderstoNewTSV("FlaskTest/static/data/commits_by_author_TEST.tsv", ['day','hour','value'])
906
-        commits_by_author_tsv=open("FlaskTest/static/data/commits_by_author_TEST.tsv", "a+")
907
-
908 907
         # Hour of Week
908
+        writeHeaderstoNewTSV("FlaskTest/static/data/hour_of_week_TEST.tsv", ['day','hour','value'])
909
+        hour_of_week_TEST=open("FlaskTest/static/data/hour_of_week_TEST.tsv", "a+")
910
+
909 911
         f.write(html_header(2, 'Hour of Week'))
910 912
         f.write('<table>')
911 913
 
@@ -925,10 +927,10 @@ class HTMLReportCreator(ReportCreator):
925 927
                     r = 127 + int((float(commits) / data.activity_by_hour_of_week_busiest) * 128)
926 928
                     f.write(' style="background-color: rgb(%d, 0, 0)"' % r)
927 929
                     f.write('>%d</td>' % commits)
928
-                    commits_by_author_tsv.write("%d\t%d\t%d\n" %(weekday,hour,commits))
930
+                    hour_of_week_TEST.write("%d\t%d\t%d\n" %(weekday+1,hour,commits))
929 931
                 else:
930 932
                     f.write('<td></td>')
931
-                    commits_by_author_tsv.write("%d\t%d\t%d\n" %(weekday,hour,0))
933
+                    hour_of_week_TEST.write("%d\t%d\t%d\n" %(weekday+1,hour,0))
932 934
             f.write('</tr>')
933 935
 
934 936
         f.write('</table>')
@@ -1020,6 +1022,17 @@ class HTMLReportCreator(ReportCreator):
1020 1022
         if len(allauthors) > conf['max_authors']:
1021 1023
             f.write('<p class="moreauthors">Only top %d authors shown</p>' % conf['max_authors'])
1022 1024
 
1025
+        authorsHEADERS=[str(author) for author in allauthors]
1026
+        authorsHEADERS.prepend("date")
1027
+
1028
+        # writes headers for both files, should have the same file
1029
+        writeHeaderstoNewTSV("FlaskTest/static/data/lines_of_code_by_author_TEST.tsv",authorsHEADERS)
1030
+        hour_of_week_TEST=open("FlaskTest/static/data/lines_of_code_by_author_TEST.tsv", "a+")
1031
+
1032
+        writeHeaderstoNewTSV("FlaskTest/static/data/commits_by_author_TEST.tsv",authorsHEADERS)
1033
+        commits_by_author_TEST=open("FlaskTest/static/data/commits_by_author_TEST.tsv", "a+")
1034
+
1035
+
1023 1036
         fgl = open(path + '/lines_of_code_by_author.dat', 'w')
1024 1037
         fgc = open(path + '/commits_by_author.dat', 'w')
1025 1038
 
@@ -1041,12 +1054,23 @@ class HTMLReportCreator(ReportCreator):
1041 1054
         for stamp in sorted(data.changes_by_date_by_author.keys()):
1042 1055
             fgl.write('%d' % stamp)
1043 1056
             fgc.write('%d' % stamp)
1057
+
1058
+            hour_of_week_TEST.write("%d\t" %(stamp))
1059
+            commits_by_author_TEST.write("%d\t" %(stamp))
1060
+
1044 1061
             for author in self.authors_to_plot:
1045 1062
                 if author in data.changes_by_date_by_author[stamp].keys():
1046 1063
                     lines_by_authors[author] = data.changes_by_date_by_author[stamp][author]['lines_added']
1047 1064
                     commits_by_authors[author] = data.changes_by_date_by_author[stamp][author]['commits']
1048 1065
                 fgl.write(' %d' % lines_by_authors[author])
1049 1066
                 fgc.write(' %d' % commits_by_authors[author])
1067
+
1068
+                hour_of_week_TEST.write("%d\t" % lines_by_authors[author] )
1069
+                commits_by_author_TEST.write("%d\t" % commits_by_authors[author] )
1070
+
1071
+            hour_of_week_TEST.write("\n")
1072
+            commits_by_author_TEST.write("\n")
1073
+
1050 1074
             fgl.write('\n')
1051 1075
             fgc.write('\n')
1052 1076
         fgl.close()