Ejemplo n.º 1
0
    def get_list (self):
        # Projects activity needs to include subprojects also
        logging.info ("Getting projects list for ITS")
        from vizgrimoire.metrics.metrics_filter import MetricFilters

        q = "SELECT p.id AS name FROM  %s.projects p" % (self.db.projects_db)
        projects = self.db.ExecuteQuery(q)
        data = []

        # Loop all projects getting reviews
        for project in projects['name']:
            type_analysis = ['project', project]

            period = None
            filter_com = MetricFilters(period, self.filters.startdate,
                                       self.filters.enddate, type_analysis)
            mclosed = ITS.get_metrics("closed", ITS)
            mclosed.filters = filter_com
            issues = mclosed.get_agg()

            issues = issues['closed']
            if (issues > 0):
                data.append([issues,project])

        # Order the list using reviews: https://wiki.python.org/moin/HowTo/Sorting
        from operator import itemgetter
        data_sort = sorted(data, key=itemgetter(0),reverse=True)
        names = [name[1] for name in data_sort]

        return({"name":names})
Ejemplo n.º 2
0
def GetClosedSummaryCompanies (period, startdate, enddate, identities_db, closed_condition, num_organizations):

    from vizgrimoire.ITS import ITS

    count = 1
    first_organizations = {}

    metric = DataSource.get_metrics("organizations", ITS)
    organizations = metric.get_list()
    organizations = organizations['name']

    for company in organizations:
        type_analysis = ["company", "'"+company+"'"]
        filter_com = MetricFilters(period, startdate, enddate, type_analysis)
        mclosed = ITS.get_metrics("closed", ITS)
        mclosed.filters = filter_com
        closed = mclosed.get_ts()
        # Rename field closed to company name
        closed[company] = closed["closed"]
        del closed['closed']

        if (count <= num_organizations):
            #Case of organizations with entity in the dataset
            first_organizations = dict(first_organizations.items() + closed.items())
        else :
            #Case of organizations that are aggregated in the field Others
            if 'Others' not in first_organizations:
                first_organizations['Others'] = closed[company]
            else:
                first_organizations['Others'] = [a+b for a, b in zip(first_organizations['Others'],closed[company])]
        count = count + 1
    first_organizations = completePeriodIds(first_organizations, period, startdate, enddate)

    return(first_organizations)
Ejemplo n.º 3
0
 def _get_sql(self, evolutionary):
     """ Implemented using Changers (changed metric should exists first) """
     close = True
     changers = ITS.get_metrics("changers", ITS)
     if changers is None:
         # We need to create changers metric
         changers = Changers(self.db, self.filters)
         q = changers._get_sql(evolutionary, close)
     else:
         cfilters = changers.filters
         changers.filters = self.filters
         q = changers._get_sql(evolutionary, close)
         changers.filters = cfilters
     return q
Ejemplo n.º 4
0
 def _get_sql(self, evolutionary):
     """ Implemented using Changed """
     close = True
     changed = ITS.get_metrics("changed", ITS)
     if changed is None:
         # We need to create changers metric
         changed = Changed(self.db, self.filters)
         q = changed._get_sql(evolutionary, close)
     else:
         cfilters = changed.filters
         changed.filters = self.filters
         q = changed._get_sql(evolutionary, close)
         changed.filters = cfilters
     return q
Ejemplo n.º 5
0
 def _get_sql(self, evolutionary):
     """ Implemented using Changers (changed metric should exists first) """
     close = True
     changers = ITS.get_metrics("changers", ITS)
     if changers is None:
         # We need to create changers metric
         changers = Changers(self.db, self.filters)
         q = changers._get_sql(evolutionary, close)
     else:
         cfilters = changers.filters
         changers.filters = self.filters
         q = changers._get_sql(evolutionary, close)
         changers.filters = cfilters
     return q
Ejemplo n.º 6
0
 def _get_sql(self, evolutionary):
     """ Implemented using Changed """
     close = True
     changed = ITS.get_metrics("changed", ITS)
     if changed is None:
         # We need to create changers metric
         changed = Changed(self.db, self.filters)
         q = changed._get_sql(evolutionary, close)
     else:
         cfilters = changed.filters
         changed.filters = self.filters
         q = changed._get_sql(evolutionary, close)
         changed.filters = cfilters
     return q
Ejemplo n.º 7
0
    def _get_top_global (self, days = 0, metric_filters = None):
        """ Implemented using Closers """
        top = None
        closers = ITS.get_metrics("closers", ITS)
        if closers is None:
            closers = Closers(self.db, self.filters)
            top = closers._get_top(days, metric_filters)
        else:
            afilters = closers.filters
            closers.filters = self.filters
            top = closers._get_top(days, metric_filters)
            closers.filters = afilters

        top['name'] = top.pop('closers')
        return top
Ejemplo n.º 8
0
    def _get_top_global(self, days=0, metric_filters=None):
        """ Implemented using Closers """
        top = None
        closers = ITS.get_metrics("closers", ITS)
        if closers is None:
            closers = Closers(self.db, self.filters)
            top = closers._get_top(days, metric_filters)
        else:
            afilters = closers.filters
            closers.filters = self.filters
            top = closers._get_top(days, metric_filters)
            closers.filters = afilters

        top['name'] = top.pop('closers')
        return top
Ejemplo n.º 9
0
    def _get_top_global (self, days = 0, metric_filters = None):
        """ Implemented using Openers """
        top = None
        openers = ITS.get_metrics("stories_openers", ITS)
        if openers is None:
            openers = StoriesOpeners(self.db, self.filters)
            top = openers._get_top(days, metric_filters)
        else:
            afilters = openers.filters
            openers.filters = self.filters
            top = openers._get_top(days, metric_filters)
            openers.filters = afilters

        top['name'] = top.pop('openers')
        return top
Ejemplo n.º 10
0
    def _get_top_global(self, days=0, metric_filters=None):
        """ Implemented using Openers """
        top = None
        openers = ITS.get_metrics("stories_openers", ITS)
        if openers is None:
            openers = StoriesOpeners(self.db, self.filters)
            top = openers._get_top(days, metric_filters)
        else:
            afilters = openers.filters
            openers.filters = self.filters
            top = openers._get_top(days, metric_filters)
            openers.filters = afilters

        top['name'] = top.pop('openers')
        return top
Ejemplo n.º 11
0
def GetClosedSummaryCompanies(period, startdate, enddate, identities_db,
                              closed_condition, num_organizations):

    from vizgrimoire.ITS import ITS

    count = 1
    first_organizations = {}

    metric = DataSource.get_metrics("organizations", ITS)
    organizations = metric.get_list()
    organizations = organizations['name']

    for company in organizations:
        type_analysis = ["company", "'" + company + "'"]
        filter_com = MetricFilters(period, startdate, enddate, type_analysis)
        mclosed = ITS.get_metrics("closed", ITS)
        mclosed.filters = filter_com
        closed = mclosed.get_ts()
        # Rename field closed to company name
        closed[company] = closed["closed"]
        del closed['closed']

        if (count <= num_organizations):
            #Case of organizations with entity in the dataset
            first_organizations = dict(first_organizations.items() +
                                       closed.items())
        else:
            #Case of organizations that are aggregated in the field Others
            if 'Others' not in first_organizations:
                first_organizations['Others'] = closed[company]
            else:
                first_organizations['Others'] = [
                    a + b for a, b in zip(first_organizations['Others'],
                                          closed[company])
                ]
        count = count + 1
    first_organizations = completePeriodIds(first_organizations, period,
                                            startdate, enddate)

    return (first_organizations)