def get_top_data_authors (startdate, enddate, i_db, filter_, npeople): top = {} mauthors = DataSource.get_metrics("authors", SCM) if mauthors is None: return top period = None type_analysis = None if filter_ is not None: type_analysis = filter_.get_type_analysis() mfilter = MetricFilters(period, startdate, enddate, type_analysis, npeople) mfilter.global_filter = mauthors.filters.global_filter if filter_ is None: top['authors.'] = mauthors.get_list(mfilter, 0) top['authors.last month'] = mauthors.get_list(mfilter, 31) top['authors.last year'] = mauthors.get_list(mfilter, 365) elif filter_.get_name() in ["company","repository","project"]: if filter_.get_name() in ["company","repository","project"]: top['authors.'] = mauthors.get_list(mfilter, 0) top['authors.last month'] = mauthors.get_list(mfilter, 31) top['authors.last year'] = mauthors.get_list(mfilter, 365) else: # If we have performance issues with tops, remove filters above # to avoid computing trends for tops top = mauthors.get_list(mfilter) else: logging.info("Top authors not support for " + filter_.get_name()) return top
def get_top_data_authors(startdate, enddate, i_db, filter_, npeople): top = {} mauthors = DataSource.get_metrics("authors", SCM) if mauthors is None: return top period = None type_analysis = None if filter_ is not None: type_analysis = filter_.get_type_analysis() mfilter = MetricFilters(period, startdate, enddate, type_analysis, npeople) mfilter.global_filter = mauthors.filters.global_filter if filter_ is None: top['authors.'] = mauthors.get_list(mfilter, 0) top['authors.last month'] = mauthors.get_list(mfilter, 31) top['authors.last year'] = mauthors.get_list(mfilter, 365) elif filter_.get_name() in ["company", "repository", "project"]: if filter_.get_name() in ["company", "repository", "project"]: top['authors.'] = mauthors.get_list(mfilter, 0) top['authors.last month'] = mauthors.get_list(mfilter, 31) top['authors.last year'] = mauthors.get_list(mfilter, 365) else: # If we have performance issues with tops, remove filters above # to avoid computing trends for tops top = mauthors.get_list(mfilter) else: logging.info("Top authors not support for " + filter_.get_name()) return top
def __get_data__ (period, startdate, enddate, identities_db, filter_ = None, evol = False): data = {} DS = SCR from vizgrimoire.GrimoireUtils import fill_and_order_items type_analysis = None if filter_ is not None: type_analysis = [filter_.get_name(), filter_.get_item()] from vizgrimoire.report import Report automator = Report.get_config() if evol: metrics_on = DS.get_metrics_core_ts() automator_metrics = DS.get_name()+"_metrics_ts" else: metrics_on = DS.get_metrics_core_agg() automator_metrics = DS.get_name()+"_metrics_agg" if automator_metrics in automator['r']: metrics_on = automator['r'][automator_metrics].split(",") logging.info(automator_metrics + " found ") # print(metrics_on) people_out = [] if "people_out" in Report.get_config()['r']: people_out = Report.get_config()['r']["people_out"] people_out = people_out.split(",") metrics_reports = SCR.get_metrics_core_reports() if filter_ is None: from vizgrimoire.report import Report reports_on = Report.get_config()['r']['reports'].split(",") for r in metrics_reports: if r in reports_on: metrics_on += [r] if type_analysis and type_analysis[1] is None: items = DS.get_filter_items(filter_, startdate, enddate, identities_db) items = items.pop('name') if DS.get_name()+"_start_date" in Report.get_config()['r']: startdate = "'"+Report.get_config()['r'][DS.get_name()+"_start_date"]+"'" if DS.get_name()+"_end_date" in Report.get_config()['r']: enddate = "'"+Report.get_config()['r'][DS.get_name()+"_end_date"]+"'" mfilter = MetricFilters(period, startdate, enddate, type_analysis, 10, people_out, None) all_metrics = SCR.get_metrics_set(SCR) # SCR specific: remove some metrics from filters if filter_ is not None: metrics_not_filters = SCR.get_metrics_not_filters() metrics_on_filters = list(set(metrics_on) - set(metrics_not_filters)) if filter_.get_name() == "repository": if 'review_time' in metrics_on: metrics_on_filters+= ['review_time'] if 'submitted' in metrics_on: metrics_on_filters+= ['submitted'] metrics_on = metrics_on_filters # END SCR specific for item in all_metrics: if item.id not in metrics_on: continue # logging.info(item.id) mfilter_orig = item.filters mfilter.global_filter = mfilter_orig.global_filter item.filters = mfilter if not evol: mvalue = item.get_agg() else: mvalue = item.get_ts() if type_analysis and type_analysis[1] is None: logging.info(item.id) id_field = SCRQuery.get_group_field_alias(type_analysis[0]) mvalue = check_array_values(mvalue) mvalue = fill_and_order_items(items, mvalue, id_field, evol, period, startdate, enddate) data = dict(data.items() + mvalue.items()) item.filters = mfilter_orig # SCR SPECIFIC # if evol: if type_analysis and type_analysis[1] is None: pass else: metrics_on_changes = ['merged','abandoned','new'] for item in all_metrics: if item.id in metrics_on_changes and filter_ is None: mfilter_orig = item.filters item.filters = mfilter mvalue = item.get_ts_changes() data = dict(data.items() + mvalue.items()) item.filters = mfilter_orig # END SCR SPECIFIC # if not evol: init_date = DS.get_date_init(startdate, enddate, identities_db, type_analysis) end_date = DS.get_date_end(startdate, enddate, identities_db, type_analysis) if type_analysis and type_analysis[1] is None: if id_field is None: id_field = dsquery.get_group_field_alias(type_analysis[0]) init_date = fill_and_order_items(items, init_date, id_field, evol, period, startdate, enddate) end_date = fill_and_order_items(items, end_date, id_field, evol, period, startdate, enddate) data = dict(data.items() + init_date.items() + end_date.items()) # Tendencies metrics_trends = SCR.get_metrics_core_trends() automator_metrics = DS.get_name()+"_metrics_trends" if automator_metrics in automator['r']: metrics_trends = automator['r'][automator_metrics].split(",") for i in [7,30,365]: for item in all_metrics: if item.id not in metrics_trends: continue mfilter_orig = item.filters item.filters = mfilter period_data = item.get_trends(enddate, i) item.filters = mfilter_orig data = dict(data.items() + period_data.items()) if type_analysis and type_analysis[1] is None: id_field = SCRQuery.get_group_field_alias(type_analysis[0]) period_data = fill_and_order_items(items, period_data, id_field) data = dict(data.items() + period_data.items()) if filter_ is not None: studies_data = {} else: studies_data = DataSource.get_studies_data(SCR, period, startdate, enddate, evol) data = dict(data.items() + studies_data.items()) return data
def get_metrics_data(DS, period, startdate, enddate, identities_db, filter_ = None, evol = False): """ Get basic data from all core metrics """ from vizgrimoire.GrimoireUtils import fill_and_order_items from vizgrimoire.ITS import ITS from vizgrimoire.MLS import MLS data = {} dsquery = DSQuery if DS == ITS: dsquery = ITSQuery if DS == MLS: dsquery = MLSQuery from vizgrimoire.report import Report automator = Report.get_config() if evol: metrics_on = DS.get_metrics_core_ts() automator_metrics = DS.get_name()+"_metrics_ts" else: metrics_on = DS.get_metrics_core_agg() automator_metrics = DS.get_name()+"_metrics_agg" if automator_metrics in automator['r']: metrics_on = automator['r'][automator_metrics].split(",") people_out = [] if "people_out" in Report.get_config()['r']: people_out = Report.get_config()['r']["people_out"] people_out = people_out.split(",") type_analysis = None if filter_ is not None: type_analysis = filter_.get_type_analysis() if type_analysis and type_analysis[1] is None: # We need the items for filling later values in group by queries items = DS.get_filter_items(filter_, startdate, enddate, identities_db) if items is None: return data items = items.pop('name') if DS.get_name()+"_startdate" in Report.get_config()['r']: startdate = Report.get_config()['r'][DS.get_name()+"_startdate"] if DS.get_name()+"_enddate" in Report.get_config()['r']: enddate = Report.get_config()['r'][DS.get_name()+"_enddate"] # TODO: the hardcoded 10 should be removed, and use instead the npeople provided # in the config file. mfilter = MetricFilters(period, startdate, enddate, type_analysis, 10, people_out, None) metrics_reports = DS.get_metrics_core_reports() all_metrics = DS.get_metrics_set(DS) # Reports = filters metrics not available inside filters if type_analysis is None: from vizgrimoire.report import Report reports_on = Report.get_config()['r']['reports'].split(",") for r in metrics_reports: if r in reports_on: metrics_on += [r] for item in all_metrics: # print item if item.id not in metrics_on: continue mfilter_orig = item.filters mfilter.global_filter = mfilter_orig.global_filter mfilter.set_closed_condition(mfilter_orig.closed_condition) item.filters = mfilter if evol: mvalue = item.get_ts() else: mvalue = item.get_agg() if type_analysis and type_analysis[1] is None and mvalue: logging.info(item.id) id_field = None # Support for combined filters for idf in mvalue.keys(): if "CONCAT(" in idf: id_field = idf break if id_field is None: id_field = dsquery.get_group_field_alias(type_analysis[0]) mvalue = fill_and_order_items(items, mvalue, id_field, evol, period, startdate, enddate) data = dict(data.items() + mvalue.items()) item.filters = mfilter_orig if not evol: init_date = DS.get_date_init(startdate, enddate, identities_db, type_analysis) end_date = DS.get_date_end(startdate, enddate, identities_db, type_analysis) if type_analysis and type_analysis[1] is None: if id_field is None: id_field = dsquery.get_group_field_alias(type_analysis[0]) init_date = fill_and_order_items(items, init_date, id_field, evol, period, startdate, enddate) end_date = fill_and_order_items(items, end_date, id_field, evol, period, startdate, enddate) if init_date is None: init_date = {} if end_date is None: end_date = {} data = dict(data.items() + init_date.items() + end_date.items()) # Tendencies metrics_trends = DS.get_metrics_core_trends() automator_metrics = DS.get_name()+"_metrics_trends" if automator_metrics in automator['r']: metrics_trends = automator['r'][automator_metrics].split(",") for i in [7,30,365]: for item in all_metrics: if item.id not in metrics_trends: continue mfilter_orig = item.filters item.filters = mfilter period_data = item.get_trends(enddate, i) item.filters = mfilter_orig if type_analysis and type_analysis[1] is None: group_field = dsquery.get_group_field_alias(type_analysis[0]) period_data = fill_and_order_items(items, period_data, group_field) data = dict(data.items() + period_data.items()) return data
def get_metrics_data(DS, period, startdate, enddate, identities_db, filter_=None, evol=False): """ Get basic data from all core metrics """ from vizgrimoire.GrimoireUtils import fill_and_order_items from vizgrimoire.ITS import ITS from vizgrimoire.MLS import MLS data = {} dsquery = DSQuery if DS == ITS: dsquery = ITSQuery if DS == MLS: dsquery = MLSQuery from vizgrimoire.report import Report automator = Report.get_config() if evol: metrics_on = DS.get_metrics_core_ts() automator_metrics = DS.get_name() + "_metrics_ts" else: metrics_on = DS.get_metrics_core_agg() automator_metrics = DS.get_name() + "_metrics_agg" if automator_metrics in automator['r']: metrics_on = automator['r'][automator_metrics].split(",") people_out = [] if "people_out" in Report.get_config()['r']: people_out = Report.get_config()['r']["people_out"] people_out = people_out.split(",") type_analysis = None if filter_ is not None: type_analysis = filter_.get_type_analysis() if type_analysis and type_analysis[1] is None: # We need the items for filling later values in group by queries items = DS.get_filter_items(filter_, startdate, enddate, identities_db) if items is None: return data items = items.pop('name') if DS.get_name() + "_startdate" in Report.get_config()['r']: startdate = Report.get_config()['r'][DS.get_name() + "_startdate"] if DS.get_name() + "_enddate" in Report.get_config()['r']: enddate = Report.get_config()['r'][DS.get_name() + "_enddate"] # TODO: the hardcoded 10 should be removed, and use instead the npeople provided # in the config file. mfilter = MetricFilters(period, startdate, enddate, type_analysis, 10, people_out, None) metrics_reports = DS.get_metrics_core_reports() all_metrics = DS.get_metrics_set(DS) # Reports = filters metrics not available inside filters if type_analysis is None: from vizgrimoire.report import Report reports_on = Report.get_config()['r']['reports'].split(",") for r in metrics_reports: if r in reports_on: metrics_on += [r] for item in all_metrics: # print item if item.id not in metrics_on: continue mfilter_orig = item.filters mfilter.global_filter = mfilter_orig.global_filter mfilter.set_closed_condition(mfilter_orig.closed_condition) item.filters = mfilter if evol: mvalue = item.get_ts() else: mvalue = item.get_agg() if type_analysis and type_analysis[1] is None and mvalue: logging.info(item.id) id_field = None # Support for combined filters for idf in mvalue.keys(): if "CONCAT(" in idf: id_field = idf break if id_field is None: id_field = dsquery.get_group_field_alias(type_analysis[0]) mvalue = fill_and_order_items(items, mvalue, id_field, evol, period, startdate, enddate) data = dict(data.items() + mvalue.items()) item.filters = mfilter_orig if not evol: init_date = DS.get_date_init(startdate, enddate, identities_db, type_analysis) end_date = DS.get_date_end(startdate, enddate, identities_db, type_analysis) if type_analysis and type_analysis[1] is None: if id_field is None: id_field = dsquery.get_group_field_alias(type_analysis[0]) init_date = fill_and_order_items(items, init_date, id_field, evol, period, startdate, enddate) end_date = fill_and_order_items(items, end_date, id_field, evol, period, startdate, enddate) if init_date is None: init_date = {} if end_date is None: end_date = {} data = dict(data.items() + init_date.items() + end_date.items()) # Tendencies metrics_trends = DS.get_metrics_core_trends() automator_metrics = DS.get_name() + "_metrics_trends" if automator_metrics in automator['r']: metrics_trends = automator['r'][automator_metrics].split(",") for i in [7, 30, 365]: for item in all_metrics: if item.id not in metrics_trends: continue mfilter_orig = item.filters item.filters = mfilter period_data = item.get_trends(enddate, i) item.filters = mfilter_orig if type_analysis and type_analysis[1] is None: group_field = dsquery.get_group_field_alias( type_analysis[0]) period_data = fill_and_order_items( items, period_data, group_field) data = dict(data.items() + period_data.items()) return data