def StaticTimeToReviewSCR (startdate, enddate, identities_db = None, type_analysis = [], bots = []): data = ExecuteQuery(GetTimeToReviewQuerySCR (startdate, enddate, identities_db, type_analysis, bots)) data = data['revtime'] if (isinstance(data, list) == False): data = [data] # ttr_median = sorted(data)[len(data)//2] if (len(data) == 0): ttr_median = float("nan") ttr_avg = float("nan") else: ttr_median = median(removeDecimals(data)) ttr_avg = average(removeDecimals(data)) return {"review_time_days_median":ttr_median, "review_time_days_avg":ttr_avg}
def EvolTimeToReviewSCR (period, startdate, enddate, identities_db = None, type_analysis = []): q = GetTimeToReviewQuerySCR (startdate, enddate, identities_db, type_analysis) review_list = ExecuteQuery(q) checkListArray(review_list) metrics_list = {"month":[],"review_time_days_median":[],"review_time_days_avg":[]} # metrics_list = {"month":[],"review_time_days_median":[]} review_list_len = len(review_list['changed_on']) if len(review_list['changed_on']) == 0: return metrics_list start = review_list['changed_on'][0] end = review_list['changed_on'][review_list_len-1] start_month = start.year*12 + start.month end_month = end.year*12 + end.month month = start_month metrics_data = [] for i in range (0,review_list_len): date = review_list['changed_on'][i] if (date.year*12 + date.month) > month: metrics_list['month'].append(month) if review_list_len == 1: metrics_data.append (review_list['revtime'][i]) if len(metrics_data) == 0: ttr_median = float('nan') ttr_avg = float('nan') else: ttr_median = median(removeDecimals(metrics_data)) ttr_avg = average(removeDecimals(metrics_data)) # avg = sum(median) / float(len(median)) # metrics_list['review_time_avg'].append(avg) metrics_list['review_time_days_median'].append(ttr_median) metrics_list['review_time_days_avg'].append(ttr_avg) metrics_data = [review_list['revtime'][i]] month = date.year*12 + date.month if i == review_list_len-1: month = date.year*12 + date.month # Close last month also if (date.year*12 + date.month) > month: metrics_data = [review_list['revtime'][i]] elif (date.year*12 + date.month) == month: metrics_data.append (review_list['revtime'][i]) metrics_list['month'].append(month) ttr_median = median(removeDecimals(metrics_data)) ttr_avg = average(removeDecimals(metrics_data)) metrics_list['review_time_days_median'].append(ttr_median) metrics_list['review_time_days_avg'].append(ttr_avg) else: metrics_data.append (review_list['revtime'][i]) return metrics_list