Subversion Repositories DevTools

Rev

Rev 4380 | Rev 4420 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4380 Rev 4381
Line 1... Line 1...
1
import json, urllib2
1
import json, urllib2, sys, datetime
2
 
2
 
3
CRUCIBLE_URL_TEMPLATE = 'http://cds:8060/rest-service/reviews-v1'
3
CRUCIBLE_URL_TEMPLATE = 'http://cds:8060/rest-service/reviews-v1'
4
RESULTS_KEY = u'results'
4
RESULTS_KEY = u'results'
5
GEOMETRY_KEY = u'geometry'
5
GEOMETRY_KEY = u'geometry'
6
LOCATION_KEY = u'location'
6
LOCATION_KEY = u'location'
Line 76... Line 76...
76
                    category_defect_map[defect_type] = 1
76
                    category_defect_map[defect_type] = 1
77
                    
77
                    
78
                self.total_defects += 1
78
                self.total_defects += 1
79
        self.selected_reviews[review_id][1] = retval[2:]    
79
        self.selected_reviews[review_id][1] = retval[2:]    
80
        return retval
80
        return retval
81
    def summarize_by_project(self, start_date, end_date) :
81
    def summarize_by_project(self, month_prefix) :
-
 
82
        start_date = month_prefix + "-00"
-
 
83
        end_date = month_prefix + "-99"
82
        print "Getting review ids"
84
        print "Getting review ids"
83
        review_ids = self.get_selected_review_ids(start_date, end_date)
85
        review_ids = self.get_selected_review_ids(start_date, end_date)
84
        project_summaries = {}
86
        project_summaries = {}
85
        overall_summary = [ 0, ] * 6
87
        overall_summary = [ 0, ] * 6
86
        for review_id in sorted(review_ids) :
88
        for review_id in sorted(review_ids) :
Line 134... Line 136...
134
    def report_on_unclassified_defects(self) : 
136
    def report_on_unclassified_defects(self) : 
135
        print "Reviews with unclassified defects: %s" % (self.unclassified_defect_reviews,)
137
        print "Reviews with unclassified defects: %s" % (self.unclassified_defect_reviews,)
136
 
138
 
137
if __name__ == "__main__" :
139
if __name__ == "__main__" :
138
    extractor = CrucibleExtractor()
140
    extractor = CrucibleExtractor()
-
 
141
    if len(sys.argv) < 2 :
-
 
142
        today = datetime.date.today()
-
 
143
        if today.month!= 1 :
-
 
144
            month_prefix = "%04d-%02d" % (today.year, today.month-1)
-
 
145
        else :
-
 
146
            month_prefix = "%04d-%02d" % (today.year-1, 12)
139
    # print extractor.get_selected_reviews('2014-03-01','2014-03-99')
147
        print "Generating report for previous month (" + month_prefix + ")"
-
 
148
    elif sys.argv[1] == "--usage" :
140
    # print extractor.get_review_summary('GSMT-5')
149
        print "crucible_reporting.py YYYY-MM"
-
 
150
        print "   report stats for specified month"
-
 
151
        print "crucible_reporting.py"
-
 
152
        print "   report stats for previous month"
-
 
153
        sys.exit(0)
-
 
154
    else :
-
 
155
        month_prefix = sys.argv[1]
-
 
156
    
141
    extractor.summarize_by_project('2014-05-01','2014-05-99')
157
    extractor.summarize_by_project(month_prefix)
142
    extractor.summarize_by_defect_type()
158
    extractor.summarize_by_defect_type()
143
    extractor.report_on_unclassified_defects()
159
    extractor.report_on_unclassified_defects()
144
 
160
 
145
 
161