示例#1
0
            return False


if __name__ == "__main__":

    from grimoirelib_alch.aux.standalone import stdout_utf8, print_banner
    from datetime import datetime, timedelta
    from scm import PeriodCondition as SCMPeriodCondition
    from scm import NomergesCondition as SCMNomergesCondition
    from its import PeriodCondition as ITSPeriodCondition

    stdout_utf8()

    # SCM database
    database = SCMDatabase(url="mysql://*****:*****@localhost/",
                           schema="vizgrimoire_cvsanaly",
                           schema_id="vizgrimoire_cvsanaly")
    session = database.build_session()

    #---------------------------------
    print_banner("List of activity for each author")
    data = SCMActivityPersons(datasource=database, name="list_authors")
    activity = data.activity()
    print activity

    #---------------------------------
    print_banner("Age (days since first activity) for each author.")
    age = activity.age(datetime(2014, 1, 1))
    print age.json()
    #---------------------------------
    print_banner("Idle (days since last activity) for each author.")
示例#2
0
        SCMActivityPersons,
        ITSActivityPersons,
        MLSActivityPersons
        )
    from grimoirelib_alch.aux.reports import create_report, add_report

    stdout_utf8()

    snapshot_date = datetime(2014,7,1)
    activity_period = timedelta(days=182)

    #---------------------------------
    print_banner("Demographics with SCM database, OpenStack")
    nomerges = SCMNomergesCondition()    
    database = SCMDatabase (url = "mysql://*****:*****@localhost/",
                            schema = "oscon_openstack_scm",
                            schema_id = "oscon_openstack_scm")
    activity = SCMActivityPersons (datasource = database,
                                   name = "list_uauthors",
                                   conditions = (nomerges,))

    report = report_demographics (activity_persons = activity,
                                  snapshot_date = snapshot_date,
                                  activity_period = activity_period,
                                  prefix = 'scm-')
    
    #---------------------------------
    print_banner("Demographics with ITS database, OpenStack")
    
    database = ITSDatabase (url = "mysql://*****:*****@localhost/",
                            schema = "oscon_openstack_its",
示例#3
0
    def result(self, data_source = None):
        """Produce result data for the analysis

        Parameters
        ----------

        data_source: SCM.SCM, MLS.MLS

        Returns
        -------

        dictionary: timezone data.
          It includes three generic components, with following keys:
          "tz": list of timezones from -12 to 11,
          "authors": list of authors for each timezone
          "authors365": list of authors for each timezone on the
              last 365 days

          Depending on the type of data source, it will contain two more keys.
          On SCM data sources:
          "commits": list of commits for each timezone
          "commits365": list of commits for each timezone on the
              last 365 days

          On MLS data sources:
          "messages": list of messages for each timezone
          "messages365": list of messages for each timezone on the
              last 365 days
        """
        logging.info("Producing data for study: Timezone")

        if data_source is None:
            logging.info("Error: no data source for study!")
            return

        if data_source not in (SCM, MLS):
            logging.info("Error: data_source not supported!")
            return

        # Prepare the SQLAlchemy database url
        url = 'mysql://' + self.db.user + ':' + \
            self.db.password + '@' + self.db.host + '/'
        schema = self.db.database
        schema_id = self.db.identities_db

        # Get startdate, endate as datetime objects
        startdate = datetime.strptime(self.filters.startdate, "'%Y-%m-%d'")
        enddate = datetime.strptime(self.filters.enddate, "'%Y-%m-%d'")

        # Get last 365 days period
        start365 = enddate - timedelta(days=365)
        end365 = enddate

        if data_source == SCM:
            logging.info("Analyzing timezone for SCM")

            nomerges = SCMNomergesCondition()
            database = SCMDatabase(url=url, schema=schema,
                                   schema_id=schema_id)

            period = SCMPeriodCondition(start=startdate, end=enddate)
            data = SCMActivityTZ(datasource=database, name="authors",
                                 conditions=(period, nomerges))

            period365 = SCMPeriodCondition(start=start365, end=end365)
            data365 = SCMActivityTZ(datasource=database, name="authors",
                                    conditions=(period365, nomerges))
        elif data_source == MLS:
            logging.info("Analyzing timezone for MLS")

            database = MLSDatabase(url=url, schema=schema,
                                   schema_id=schema_id)

            period = MLSPeriodCondition(start=startdate, end=enddate,
                                        date="first")
            data = MLSActivityTZ(datasource=database, name="senders",
                                 conditions=(period,))

            period365 = MLSPeriodCondition(start=start365, end=end365,
                                           date="first")
            data365 = MLSActivityTZ(datasource=database, name="senders",
                                    conditions=(period365,))

        timezones = data.timezones()
        timezones365 = data365.timezones()

        if data_source == SCM:
            timezones['commits365'] = timezones365['commits']
        elif data_source == MLS:
            timezones['messages365'] = timezones365['messages']

        timezones['authors365'] = timezones365['authors']

        return timezones
示例#4
0
    def result(self, data_source = None):
        """Produce result data for the analysis

        Parameters
        ----------

        data_source: { SCM.SCM | ITS.ITS | MLS.MLS }

        Returns
        -------

        dictionary: birth and aging data.
          The dictionary has two entries, keyed "birth" and "data".
          For each of them, information about the duration of all actors
          in the project is included.

        """

        logging.info("Producing data for study: Aging")
        if data_source is None:
            logging.info("Error: no data source for study!")
            return
        # Prepare the SQLAlchemy database url
        url = 'mysql://' + self.db.user + ':' + \
            self.db.password + '@' + self.db.host + '/'
        schema = self.db.database
        schema_id = self.db.identities_db
        # Get startdate, endate as datetime objects
        startdate = datetime.strptime(self.filters.startdate, "'%Y-%m-%d'")
        enddate = datetime.strptime(self.filters.enddate, "'%Y-%m-%d'")
        # Get dictionary with analysis, if any
        self.analysis_dict = parse_analysis (self.filters.type_analysis)
        if data_source == SCM:
            logging.info("Analyzing aging for SCM")
            # Activity data (start time, end time for contributions) for
            # all the actors, considering only activty during
            # the startdate..enddate period (merges are not considered
            # as activity)
            period = SCMPeriodCondition (start = startdate, end = enddate)
            nomerges = SCMNomergesCondition()
            conditions = [period, nomerges]
            if self.filters.COMPANY in self.analysis_dict:
                orgs = SCMOrgsCondition (
                    orgs = (self.analysis_dict[self.filters.COMPANY],),
                    actors = "authors")
                conditions.append(orgs)
            database = SCMDatabase (url = url,
                                    schema = schema,
                                    schema_id = schema_id)
            data = SCMActivityPersons (
                datasource = database,
                name = "list_uauthors",
                conditions = conditions)
        elif data_source == ITS:
            logging.info("Analyzing aging for ITS")
            # Activity data (start time, end time for contributions) for
            # all the actors, considering only activty during
            # the startdate..enddate period
            period = ITSPeriodCondition (start = startdate, end = enddate)
            conditions = [period,]
            if self.filters.COMPANY in self.analysis_dict:
                orgs = ITSOrgsCondition (
                    orgs = (self.analysis_dict[self.filters.COMPANY],)
                    )
                conditions.append(orgs)
            database = ITSDatabase (url = url,
                                    schema = schema,
                                    schema_id = schema_id)
            data = ITSActivityPersons (
                datasource = database,
                name = "list_uchangers",
                conditions = conditions)
        elif data_source == MLS:
            logging.info("Analyzing aging for MLS")
            # Activity data (start time, end time for contributions) for
            # all the actors, considering only activty during
            # the startdate..enddate period
            period = MLSPeriodCondition (start = startdate,
                                         end = enddate,
                                         date = "check")
            conditions = [period,]
            if self.filters.COMPANY in self.analysis_dict:
                orgs = MLSOrgsCondition (
                    orgs = (self.analysis_dict[self.filters.COMPANY],),
                    actors = "senders",
                    date = "check"
                    )
                conditions.append(orgs)
            database = MLSDatabase (url = url,
                                    schema = schema,
                                    schema_id = schema_id)
            data = MLSActivityPersons (
                datasource = database,
                name = "list_usenders",
                date_kind = "check",
                conditions = conditions)
        else:
            logging.info("Error: No aging analysis for this data source!")
        if data_source in (SCM, ITS, MLS):
            # Birth has the ages of all actors, consiering enddate as
            # current (snapshot) time
            snapshot = SnapshotCondition (date = enddate)
            birth = DurationPersons (datasource = data,
                                     name = "age",
                                     conditions = (snapshot,),
                                     )
            # "Aging" has the ages of those actors active during the 
            # last half year (that is, the period from enddate - half year
            # to enddate)
            active_period = ActiveCondition (after = enddate - \
                                                 timedelta(days=182),
                                             before = enddate)
            aging = DurationPersons (datasource = data,
                                     name = "age",
                                     conditions = (snapshot, active_period),
                                     )
            demos = {"birth": birth.durations(),
                     "aging": aging.durations()}
            return demos
        else:
            return {"birth": {},
                    "aging": {}}
示例#5
0
            raise Exception ("MLSActivityTZ: " + \
                                 "Invalid entity name for this family, " + \
                                 name)


if __name__ == "__main__":

    from grimoirelib_alch.aux.standalone import stdout_utf8, print_banner
    from scm import PeriodCondition as SCMPeriodCondition
    from scm import NomergesCondition as SCMNomergesCondition
    from datetime import datetime, timedelta

    stdout_utf8()

    database = SCMDatabase (url = "mysql://*****:*****@localhost/",
                   schema = "oscon_opennebula_scm_tz",
                   schema_id = "oscon_opennebula_scm_tz")

    #---------------------------------
    print_banner("Author activity per time zone")
    data = SCMActivityTZ (
        datasource = database,
        name = "authors")
    tz = data.timezones()
    print tz

    #---------------------------------
    print_banner("Author activity per time zone (now using session)")
    session = database.build_session(query_cls = SCMTZQuery)
    data = SCMActivityTZ (
        datasource = session,
示例#6
0
    from sqlalchemy import func, and_
    from sqlalchemy.sql import label

    stdout_utf8()

    prefix = "maturity-"
    month_end = analysis_date
    month_start = analysis_date - timedelta(days=30)

    #
    # SCM
    #

    database = SCMDatabase(url=scm_database["url"],
                           schema=scm_database["schema"],
                           schema_id=scm_database["schema_id"])
    session = database.build_session()

    # Get SCM repository ids
    query = session.query(
        label("id", SCMDatabase.Repositories.id)
        ) \
        .filter (SCMDatabase.Repositories.name.in_ (scm_repos_name))
    scm_repos = [row.id for row in query.all()]
    print scm_repos
    # Get SCM branche ids
    query = session.query(
        label("id", SCMDatabase.Branches.id)
        ) \
        .filter (SCMDatabase.Branches.name.in_ (scm_branches_name))