Ejemplo n.º 1
0
 def fetch(self):
     log.info("Searching for bugs posted by {0}".format(self.user))
     query = {
         # User is the assignee
         "f1": "assigned_to",
         "o1": "equals",
         "v1": self.user.email,
         # Status changed to POST
         "f2": "bug_status",
         "o2": "changedto",
         "v2": "POST",
         # Since date
         "f3": "bug_status",
         "o3": "changedafter",
         "v3": str(self.options.since),
         # Until date
         "f4": "bug_status",
         "o4": "changedbefore",
         "v4": str(self.options.until),
     }
     self.stats = [
         bug
         for bug in self.parent.bugzilla.search(query, options=self.options)
         if bug.posted()
     ]
Ejemplo n.º 2
0
 def fetch(self):
     log.info("Searching for Issues closed by {0}".format(self.user))
     results = self.parent.gitlab.search(self.user.login,
                                         self.options.since,
                                         self.options.until, 'Issue',
                                         'closed')
     self.stats = [Issue(issue, self.parent.gitlab) for issue in results]
Ejemplo n.º 3
0
Archivo: base.py Proyecto: barraq/did
    def __init__(self, config=None, path=None):
        """
        Read the config file

        Parse config from given string (config) or file (path).
        If no config or path given, default to "~/.did/config" which
        can be overrided by the ``DID_DIR`` environment variable.
        """
        # Read the config only once (unless explicitly provided)
        if self.parser is not None and config is None and path is None:
            return
        Config.parser = ConfigParser.SafeConfigParser()
        # If config provided as string, parse it directly
        if config is not None:
            log.info("Inspecting config file from string")
            log.debug(utils.pretty(config))
            self.parser.readfp(StringIO.StringIO(config))
            return
        # Check the environment for config file override
        # (unless path is explicitly provided)
        if path is None:
            path = Config.path()
        # Parse the config from file
        try:
            log.info("Inspecting config file '{0}'.".format(path))
            self.parser.readfp(codecs.open(path, "r", "utf8"))
        except IOError as error:
            log.debug(error)
            Config.parser = None
            raise ConfigFileError(
                "Unable to read the config file '{0}'.".format(path))
Ejemplo n.º 4
0
 def fetch(self):
     log.info(u"Searching for issues closed by {0}".format(self.user))
     query = "search/issues?q=assignee:{0}+closed:{1}..{2}".format(
         self.user.login, self.options.since, self.options.until)
     self.stats = [
         Issue(issue) for issue in self.parent.github.search(query)
     ]
Ejemplo n.º 5
0
 def fetch(self):
     log.info(u"Searching for changes reviewed by {0}".format(self.user))
     # Collect ALL changes opened (and perhaps now closed) after
     # given date and collect all reviews from them ... then limit by
     # actual reviewer (not reviewer:<login> because that doesn’t
     # that the person actually did a review, only that it has
     # a right to do so).
     self.stats = []
     reviewer = self.user.login
     tickets = GerritUnit.fetch(
         self, "reviewer:{0}+is:closed&q=reviewer:{0}+is:open".format(self.user.login), "", limit_since=True
     )
     for tck in tickets:
         log.debug("ticket = {0}".format(tck))
         try:
             changes = self.repo.get_changelog(tck)
         except IOError:
             log.debug("Failing to retrieve details for {0}".format(tck.change_id))
             continue
         log.debug("changes.messages = {0}".format(pretty(changes["messages"])))
         cmnts_by_user = []
         for chg in changes["messages"]:
             if "author" in chg and reviewer in chg["author"]["email"]:
                 comment_date = self.get_gerrit_date(chg["date"][:10])
                 if comment_date >= self.since_date:
                     cmnts_by_user.append(chg)
         if len(cmnts_by_user) > 0:
             self.stats.append(Change(tck.ticket, changelog=changes, prefix=self.prefix))
     log.debug(u"self.stats = {0}".format(self.stats))
Ejemplo n.º 6
0
 def fetch(self):
     log.info(u"Searching for resolved issues by {0}".format(self.user))
     for activity in self.filter_data():
         if (activity['user']['email'] == self.user.email and
                 activity['type'] == 'set_resolved'):
             self.stats.append("{0} - {1}".format(
                 activity['issue']['shortId'], activity['issue']['title']))
Ejemplo n.º 7
0
 def fetch(self):
     log.info(u"Searching for tickets closed by {0}".format(self.user))
     query = "owner=~{0}&time=..{2}&modified={1}..".format(
         self.user.login, self.options.since, self.options.until)
     self.stats = [
         ticket for ticket in Trac.search(query, self.parent, self.options)
         if ticket.closed()]
Ejemplo n.º 8
0
    def fetch(self):
        log.info(u"Searching for patches added to changes by {0}".format(self.user))
        reviewer = self.user.login
        self.stats = []
        tickets = GerritUnit.fetch(
            self, "owner:{0}+is:closed&q=owner:{0}+is:open".format(reviewer), "", limit_since=True
        )
        for tck in tickets:
            log.debug("ticket = {0}".format(tck))
            try:
                changes = self.repo.get_changelog(tck)
            except IOError:
                log.debug("Failing to retrieve details for {0}".format(tck.change_id))
                continue

            owner = changes["owner"]["email"]

            log.debug("changes.messages = {0}".format(pretty(changes["messages"])))
            cmnts_by_user = []
            for chg in changes["messages"]:
                # TODO This is a very bad algorithm for recognising
                # patch setts added by the owner of the change, but
                # I don’t know how to find a list of all revisions for
                # the particular change.
                if (
                    "author" in chg
                    and owner == chg["author"]["email"]
                    and self.get_gerrit_date(chg["date"][:10]) >= self.since_date
                    and "uploaded patch" in chg["message"].lower()
                ):
                    cmnts_by_user.append(chg)
            if len(cmnts_by_user) > 0:
                self.stats.append(Change(tck.ticket, changelog=changes, prefix=self.prefix))
        log.debug(u"self.stats = {0}".format(self.stats))
Ejemplo n.º 9
0
 def fetch(self):
     log.info(u"Searching for issues created by {0}".format(self.user))
     query = "search/issues?q=author:{0}+created:{1}..{2}".format(
         self.user.login, self.options.since, self.options.until)
     query += "+type:issue"
     self.stats = [
             Issue(issue) for issue in self.parent.github.search(query)]
Ejemplo n.º 10
0
 def fetch(self):
     log.info(u"Searching for resolved issues by {0}".format(self.user))
     for activity in self.filter_data():
         if (activity['user']['email'] == self.user.email
                 and activity['type'] == 'set_resolved'):
             self.stats.append("{0} - {1}".format(
                 activity['issue']['shortId'], activity['issue']['title']))
Ejemplo n.º 11
0
 def fetch(self):
     log.info(u"Searching for bugs returned by {0}".format(self.user))
     query = {
         # User is not the assignee
         "f1": "assigned_to",
         "o1": "notequals",
         "v1": self.user.email,
         # Status changed to ASSIGNED
         "f2": "bug_status",
         "o2": "changedto",
         "v2": "ASSIGNED",
         # Changed by the user
         "f5": "bug_status",
         "o5": "changedby",
         "v5": self.user.email,
         # Since date
         "f3": "bug_status",
         "o3": "changedafter",
         "v3": str(self.options.since),
         # Until date
         "f4": "bug_status",
         "o4": "changedbefore",
         "v4": str(self.options.until),
         }
     self.stats = [
         bug for bug in self.parent.bugzilla.search(
             query, options=self.options)
         if bug.returned(self.user)]
Ejemplo n.º 12
0
 def fetch(self):
     log.info(u"Searching for bugs closed by {0}".format(self.user))
     query = {
         # Status changed by the user
         "f1": "bug_status",
         "o1": "changedby",
         "v1": self.user.email,
         # Status changed to CLOSED
         "f2": "bug_status",
         "o2": "changedto",
         "v2": "CLOSED",
         # Since date
         "f3": "bug_status",
         "o3": "changedafter",
         "v3": str(self.options.since),
         # Until date
         "f4": "bug_status",
         "o4": "changedbefore",
         "v4": str(self.options.until),
         # Status is now CLOSED
         "f5": "bug_status",
         "o5": "equals",
         "v5": "CLOSED",
         }
     self.stats = [
         bug for bug in self.parent.bugzilla.search(
             query, options=self.options)
         if bug.closed(self.user)]
Ejemplo n.º 13
0
    def fetch(self, page_size=100):
        log.info("Searching for idonethis.com dones in {0}".format(
            self.parent.option))

        # FIXME: add support for pagination (eg, done >= page_size)
        # FIXME: filter out all 'planned' dones (eg, prefixed with '[ ]')

        params = {
            'done_date_after': unicode(self.parent.options.since),
            'done_date_before': unicode(self.parent.options.until),
            'page_size': page_size,
        }
        response = self.parent.session.get(ROOT_URI, params=params)

        if response.status_code not in (400, 401):
            response.raise_for_status()

        payload = response.json()

        if not payload.get('ok'):
            detail = payload.get('detail') or 'UNKNOWN ERROR'
            raise did.base.ReportError(
                "Failed to fetch idonethis items ({0})".format(detail))

        k = payload['count']
        log.info('Found {0} dones'.format(k))
        msg = '[{0}] <{1}> {2}'
        results = payload.get('results') or []
        stats = [
            msg.format(x['done_date'], x['owner'], x['raw_text'])
            for x in results
        ]
        self.stats = sorted(stats)
Ejemplo n.º 14
0
 def fetch(self):
     log.info(u"Searching for bugs patched by {0}".format(self.user))
     query = {
         # Keywords field changed by the user
         "field0-0-0": "keywords",
         "type0-0-0": "changedby",
         "value0-0-0": self.user.email,
         # Patch keyword added
         "field0-1-0": "keywords",
         "type0-1-0": "changedto",
         "value0-1-0": "Patch",
         # Since date
         "field0-2-0": "keywords",
         "type0-2-0": "changedafter",
         "value0-2-0": str(self.options.since),
         # Until date
         "field0-3-0": "keywords",
         "type0-3-0": "changedbefore",
         "value0-3-0": str(self.options.until),
     }
     self.stats = [
         bug
         for bug in self.parent.bugzilla.search(query, options=self.options)
         if bug.patched(self.user)
     ]
Ejemplo n.º 15
0
    def __init__(self, config=None, path=None):
        """
        Read the config file

        Parse config from given string (config) or file (path).
        If no config or path given, default to "~/.did/config" which
        can be overrided by the ``DID_DIR`` environment variable.
        """
        # Read the config only once (unless explicitly provided)
        if self.parser is not None and config is None and path is None:
            return
        Config.parser = ConfigParser.SafeConfigParser()
        # If config provided as string, parse it directly
        if config is not None:
            log.info("Inspecting config file from string")
            log.debug(utils.pretty(config))
            self.parser.readfp(StringIO.StringIO(config))
            return
        # Check the environment for config file override
        # (unless path is explicitly provided)
        if path is None:
            path = Config.path()
        # Parse the config from file
        try:
            log.info("Inspecting config file '{0}'.".format(path))
            self.parser.readfp(codecs.open(path, "r", "utf8"))
        except IOError as error:
            log.debug(error)
            Config.parser = None
            raise ConfigFileError(
                "Unable to read the config file '{0}'.".format(path))
Ejemplo n.º 16
0
 def fetch(self):
     log.info(u"Searching for bugs closed by {0}".format(self.user))
     query = {
         # User is the assignee
         "field0-0-0": "assigned_to",
         "type0-0-0": "equals",
         "value0-0-0": self.user.email,
         # Status changed to CLOSED
         "field0-1-0": "bug_status",
         "type0-1-0": "changedto",
         "value0-1-0": "CLOSED",
         # Since date
         "field0-2-0": "bug_status",
         "type0-2-0": "changedafter",
         "value0-2-0": str(self.options.since),
         # Until date
         "field0-3-0": "bug_status",
         "type0-3-0": "changedbefore",
         "value0-3-0": str(self.options.until),
         # Status is now CLOSED
         "field0-4-0": "bug_status",
         "type0-4-0": "equals",
         "value0-4-0": "CLOSED",
     }
     self.stats = [
         bug
         for bug in self.parent.bugzilla.search(query, options=self.options)
         if bug.closed(self.user)
     ]
Ejemplo n.º 17
0
 def fetch(self):
     log.info(u"Searching for bugs verified by {0}".format(self.user))
     query = {
         # User is the QA contact
         "field0-0-0": "qa_contact",
         "type0-0-0": "equals",
         "value0-0-0": self.user.email,
         # Status changed to VERIFIED
         "field0-1-0": "bug_status",
         "type0-1-0": "changedto",
         "value0-1-0": "VERIFIED",
         # Since date
         "field0-2-0": "bug_status",
         "type0-2-0": "changedafter",
         "value0-2-0": str(self.options.since),
         # Until date
         "field0-3-0": "bug_status",
         "type0-3-0": "changedbefore",
         "value0-3-0": str(self.options.until)
     }
     self.stats = [
         bug
         for bug in self.parent.bugzilla.search(query, options=self.options)
         if bug.verified()
     ]
Ejemplo n.º 18
0
 def fetch(self):
     import nitrate
     log.info("Searching for test runs finished by {0}".format(self.user))
     self.stats.extend(
         nitrate.TestRun.search(default_tester__email=self.user.email,
                                stop_date__gt=str(self.options.since),
                                stop_date__lt=str(self.options.until)))
Ejemplo n.º 19
0
 def fetch(self):
     log.info(u"Searching for bugs verified by {0}".format(self.user))
     query = {
         # Status changed to VERIFIED
         "f1": "bug_status",
         "o1": "changedto",
         "v1": "VERIFIED",
         # Since date
         "f2": "bug_status",
         "o2": "changedafter",
         "v2": str(self.options.since),
         # Until date
         "f3": "bug_status",
         "o3": "changedbefore",
         "v3": str(self.options.until),
         # Operator OR
         "f4": "OP",
         "j4": "OR",
         # User is the QA contact
         "f5": "qa_contact",
         "o5": "equals",
         "v5": self.user.email,
         # User changed the bug state
         "f6": "bug_status",
         "o6": "changedby",
         "v6": self.user.email,
     }
     self.stats = [
         bug
         for bug in self.parent.bugzilla.search(query, options=self.options)
         if bug.verified()
     ]
Ejemplo n.º 20
0
 def fetch(self):
     log.info(u"Searching for bugs closed by {0}".format(self.user))
     query = {
         # Status changed by the user
         "field0-0-0": "bug_status",
         "type0-0-0": "changedby",
         "value0-0-0": self.user.email,
         # Status changed to CLOSED
         "field0-1-0": "bug_status",
         "type0-1-0": "changedto",
         "value0-1-0": "CLOSED",
         # Since date
         "field0-2-0": "bug_status",
         "type0-2-0": "changedafter",
         "value0-2-0": str(self.options.since),
         # Until date
         "field0-3-0": "bug_status",
         "type0-3-0": "changedbefore",
         "value0-3-0": str(self.options.until),
         # Status is now CLOSED
         "field0-4-0": "bug_status",
         "type0-4-0": "equals",
         "value0-4-0": "CLOSED",
         }
     self.stats = [
         bug for bug in self.parent.bugzilla.search(
             query, options=self.options)
         if bug.closed(self.user)]
Ejemplo n.º 21
0
 def fetch(self):
     log.info("Searching for bugs returned by {0}".format(self.user))
     query = {
         # User is not the assignee
         "field0-0-0": "assigned_to",
         "type0-0-0": "notequals",
         "value0-0-0": self.user.email,
         # Status changed to ASSIGNED
         "field0-1-0": "bug_status",
         "type0-1-0": "changedto",
         "value0-1-0": "ASSIGNED",
         # Changed by the user
         "field0-4-0": "bug_status",
         "type0-4-0": "changedby",
         "value0-4-0": self.user.email,
         # Since date
         "field0-2-0": "bug_status",
         "type0-2-0": "changedafter",
         "value0-2-0": str(self.options.since),
         # Until date
         "field0-3-0": "bug_status",
         "type0-3-0": "changedbefore",
         "value0-3-0": str(self.options.until),
     }
     self.stats = [
         bug for bug in self.parent.bugzilla.search(query, options=self.options) if bug.returned(self.user)
     ]
Ejemplo n.º 22
0
    def fetch(self, page_size=100):
        log.info(
            "Searching for idonethis.com dones in {0}".format(
                self.parent.option))

        # FIXME: add support for pagination (eg, done >= page_size)
        # FIXME: filter out all 'planned' dones (eg, prefixed with '[ ]')

        params = {
            'done_date_after': unicode(self.parent.options.since),
            'done_date_before': unicode(self.parent.options.until),
            'page_size': page_size,
        }
        response = self.parent.session.get(ROOT_URI, params=params)

        if response.status_code not in (400, 401):
            response.raise_for_status()

        payload = response.json()

        if not payload.get('ok'):
            detail = payload.get('detail') or 'UNKNOWN ERROR'
            raise did.base.ReportError(
                "Failed to fetch idonethis items ({0})".format(detail))

        k = payload['count']
        log.info('Found {0} dones'.format(k))
        msg = '[{0}] <{1}> {2}'
        results = payload.get('results') or []
        stats = [msg.format(x['done_date'], x['owner'], x['raw_text'])
                 for x in results]
        self.stats = sorted(stats)
Ejemplo n.º 23
0
 def fetch(self):
     import nitrate
     log.info(u"Searching for test runs finished by {0}".format(self.user))
     self.stats.extend(nitrate.TestRun.search(
         default_tester__email=self.user.email,
         stop_date__gt=str(self.options.since),
         stop_date__lt=str(self.options.until)))
Ejemplo n.º 24
0
def detect():
    """
    Detect available plugins and return enabled/configured stats

    Yields tuples of the form (section, statsgroup) sorted by the
    default StatsGroup order which maybe overriden in the config
    file. The 'section' is the name of the configuration section
    as well as the option used to enable those particular stats.
    """

    # Load plugins and config
    plugins = load()
    config = Config()

    # Make sure that all sections have a valid plugin type defined
    for section in config.sections():
        if section == 'general':
            continue
        try:
            type_ = config.item(section, 'type')
        except ConfigError:
            raise ConfigError(
                "Plugin type not defined in section '{0}'.".format(section))
        if type_ not in plugins:
            raise ConfigError(
                "Invalid plugin type '{0}' in section '{1}'.".format(
                    type_, section))

    # Detect classes inherited from StatsGroup and return them sorted
    stats = []
    for plugin in plugins:
        module = getattr(PLUGINS, plugin)
        for object_name in dir(module):
            statsgroup = getattr(module, object_name)
            # Filter out anything except for StatsGroup descendants
            if (not isinstance(statsgroup, (type, types.ClassType))
                    or not issubclass(statsgroup, StatsGroup)
                    or statsgroup is StatsGroup
                    or statsgroup is EmptyStatsGroup):
                continue
            # Search config for sections with type matching the plugin,
            # use order provided there or class default otherwise
            for section in config.sections(kind=plugin):
                try:
                    order = int(config.item(section, "order"))
                except ConfigError:
                    order = statsgroup.order
                except ValueError:
                    log.warn("Invalid {0} stats order: '{1}'".format(
                        section, config.item(section, "order")))
                    order = statsgroup.order
                stats.append((section, statsgroup, order))
                log.info("Found {0}, an instance of {1}, order {2}".format(
                    section, statsgroup.__name__, order))
                # Custom stats are handled with a single instance
                if statsgroup.__name__ == "CustomStats":
                    break
    for section, statsgroup, _ in sorted(stats, key=lambda x: x[2]):
        yield section, statsgroup
Ejemplo n.º 25
0
Archivo: google.py Proyecto: psss/did
 def tasks(self):
     """ All completed tasks within specified time range """
     if self._tasks is None:
         self._tasks = self.parent.tasks.tasks(
             tasklist="@default", showCompleted="true", showHidden="true",
             completedMin=self.since, completedMax=self.until)
     log.info(u"NB TASKS {0}".format(len(self._tasks)))
     return self._tasks
Ejemplo n.º 26
0
 def fetch(self):
     import nitrate
     log.info("Searching for test plans created by {0}".format(self.user))
     self.stats.extend(
         nitrate.TestPlan.search(is_active=True,
                                 author__email=self.user.email,
                                 create_date__gt=str(self.options.since),
                                 create_date__lt=str(self.options.until)))
Ejemplo n.º 27
0
 def fetch(self):
     log.info("Searching for issues created in {0} by {1}".format(
         self.parent.project, self.user))
     query = ("project = '{0}' AND creator = '{1}' AND "
              "created >= {2} AND created <= {3}".format(
                  self.parent.project, self.user.email, self.options.since,
                  self.options.until))
     self.stats = Issue.search(query, stats=self)
Ejemplo n.º 28
0
Archivo: pagure.py Proyecto: psss/did
 def fetch(self):
     log.info(u'Searching for issues created by {0}'.format(self.user))
     issues = [Issue(issue) for issue in self.parent.pagure.search(
         query='user/{0}/issues?assignee=false&created={1}..{2}'.format(
             self.user.login, self.options.since, self.options.until),
         pagination='pagination_issues_created',
         result_field='issues_created')]
     self.stats = sorted(issues, key=lambda i: unicode(i))
Ejemplo n.º 29
0
 def tasks(self):
     """ All completed tasks within specified time range """
     if self._tasks is None:
         self._tasks = self.parent.tasks.tasks(
             tasklist="@default", showCompleted="true", showHidden="true",
             completedMin=self.since, completedMax=self.until)
     log.info("NB TASKS {0}".format(len(self._tasks)))
     return self._tasks
Ejemplo n.º 30
0
 def fetch(self):
     import nitrate
     log.info(u"Searching for test plans created by {0}".format(self.user))
     self.stats.extend(nitrate.TestPlan.search(
         is_active=True,
         author__email=self.user.email,
         create_date__gt=str(self.options.since),
         create_date__lt=str(self.options.until)))
Ejemplo n.º 31
0
 def fetch(self):
     log.info("Searching for tickets closed by {0}".format(self.user))
     query = "owner=~{0}&time=..{2}&modified={1}..".format(
         self.user.login, self.options.since, self.options.until)
     self.stats = [
         ticket for ticket in Trac.search(query, self.parent, self.options)
         if ticket.closed()
     ]
Ejemplo n.º 32
0
Archivo: gerrit.py Proyecto: psss/did
 def fetch(self):
     log.info("Searching for WIP changes opened by {0}".format(self.user))
     if 'wip' not in self.server_features:
         log.debug("WIP reviews are not supported by this server")
         return []
     self.stats = GerritUnit.fetch(self, 'status:open is:wip',
                                   limit_since=True)
     log.debug("self.stats = {0}".format(self.stats))
Ejemplo n.º 33
0
 def fetch(self):
     log.info("Searching for Merge requests approved by {0}".format(
         self.user))
     results = self.parent.gitlab.search(self.user.login,
                                         self.options.since,
                                         self.options.until, 'MergeRequest',
                                         'approved')
     self.stats = [MergeRequest(mr, self.parent.gitlab) for mr in results]
Ejemplo n.º 34
0
 def fetch(self):
     log.info("Searching for pages created by {0}".format(self.user))
     query = ("type=page AND creator = '{0}' "
              "AND created >= {1} AND created < {2}".format(
                  self.user.login, self.options.since, self.options.until))
     self.stats = [
         ConfluencePage(page) for page in Confluence.search(query, self)
     ]
Ejemplo n.º 35
0
 def fetch(self):
     log.info("Searching for changes opened by {0}".format(self.user))
     if 'wip' in self.server_features:
         query_string = 'status:open -is:wip'
     else:
         query_string = 'status:open'
     self.stats = GerritUnit.fetch(self, query_string, limit_since=True)
     log.debug("self.stats = {0}".format(self.stats))
Ejemplo n.º 36
0
 def fetch(self):
     log.info(u"Searching for pull requests reviewed by {0}".format(
         self.user))
     query = "search/issues?q=reviewed-by:{0}+closed:{1}..{2}".format(
         self.user.login, self.options.since, self.options.until)
     query += "+type:pr"
     self.stats = [
             Issue(issue) for issue in self.parent.github.search(query)]
Ejemplo n.º 37
0
 def fetch(self):
     log.info("Searching for issues resolved in {0} by {1}".format(
         self.parent.project, self.user))
     query = ("project = '{0}' AND assignee = '{1}' AND "
              "resolved >= {2} AND resolved <= {3}".format(
                  self.parent.project, self.user.login, self.options.since,
                  self.options.until))
     self.stats = Issue.search(query, stats=self)
Ejemplo n.º 38
0
    def fetch(self):
        log.info("Searching for bugs patched by {0}".format(self.user))
        query = {
            # Keywords field changed by the user
            "f1": "keywords",
            "o1": "changedby",
            "v1": self.user.email,
            # Patch keyword added
            "f2": "keywords",
            "o2": "changedto",
            "v2": "Patch",
            # Since date
            "f3": "keywords",
            "o3": "changedafter",
            "v3": str(self.options.since),
            # Until date
            "f4": "keywords",
            "o4": "changedbefore",
            "v4": str(self.options.until),
        }
        self.stats = [
            bug
            for bug in self.parent.bugzilla.search(query, options=self.options)
            if bug.patched(self.user)
        ]

        # When user adds the Patch keyword when creating a bug, there is no
        # action in the bug's history from which this would be apparent. We
        # therefore need to check if there are any bugs reported by the user
        # which contain the Patch keyword but have no such action in their
        # history.
        query = {
            # Reported by user
            "f1": "reporter",
            "o1": "equals",
            "v1": self.user.email,
            # Since date
            "f2": "creation_ts",
            "o2": "greaterthan",
            "v2": str(self.options.since),
            # Until date
            "f3": "creation_ts",
            "o3": "lessthan",
            "v3": str(self.options.until),
            # Keywords contain Patch
            "f4": "keywords",
            "o4": "substring",
            "v4": "Patch",
            # The keyword was added when creating the bug
            "n5": "1",
            "f5": "keywords",
            "o5": "changedto",
            "v5": "Patch",
        }
        self.stats += [
            bug
            for bug in self.parent.bugzilla.search(query, options=self.options)
        ]
Ejemplo n.º 39
0
    def fetch(self, query_string="", common_query_options=None, limit_since=False):
        """
        Backend for the actual gerrit query.

        query_string:
            basic query terms, e.g., 'status:abandoned'
        common_query_options:
            [optional] rest of the query string; if omitted, the default
            one is used (limit by the current user and since option);
            if empty, nothing will be added to query_string
        limit_since:
            [optional] Boolean (defaults to False) post-process the results
            to eliminate items created after since option.
        """
        work_list = []
        log.info(u"Searching for changes abandoned by {0}".format(self.user))
        log.debug("query_string = {0}, common_query_options = {1}".format(query_string, common_query_options))

        self.since_date = self.get_gerrit_date(self.options.since)

        if common_query_options is None:
            # Calculate age from self.options.since
            #
            # Amount of time that has expired since the change was last
            # updated with a review comment or new patch set.
            #
            # Meaning that the last time we changed the review is
            # GREATER than the given age.
            # For age SMALLER we need -age:<time>

            common_query_options = "+owner:{0}".format(self.user.login)
            if not limit_since:
                age = (TODAY - self.since_date).days
                common_query_options += "+-age:{0}d".format(age)

        if isinstance(common_query_options, basestring) and len(common_query_options) > 0:
            query_string += common_query_options

        log.debug("query_string = {0}".format(query_string))
        log.debug("self.prefix = {0}".format(self.prefix))
        log.debug("[fetch] self.base_url = {0}".format(self.base_url))
        work_list = self.repo.search(query_string)

        if limit_since:
            tmplist = []
            log.debug("Limiting by since option")
            self.stats = []
            for chg in work_list:
                log.debug("chg = {0}".format(chg))
                chg_created = self.get_gerrit_date(chg["created"][:10])
                log.debug("chg_created = {0}".format(chg_created))
                if chg_created >= self.since_date:
                    tmplist.append(chg)
            work_list = tmplist[:]
        log.debug(u"work_list = {0}".format(work_list))

        # Return the list of tick_data objects
        return [Change(ticket, prefix=self.prefix) for ticket in work_list]
Ejemplo n.º 40
0
 def fetch(self):
     log.info("Searching for comments added by {0}".format(self.user))
     query = ("type=comment AND creator = '{0}' "
              "AND created >= {1} AND created < {2}".format(
                  self.user.login, self.options.since, self.options.until))
     self.stats = [
         ConfluenceComment(comment)
         for comment in Confluence.search(query, self, expand="body.editor")
     ]
Ejemplo n.º 41
0
Archivo: pagure.py Proyecto: psss/did
 def fetch(self):
     log.info(u'Searching for pull requests created by {0}'.format(
         self.user))
     issues = [Issue(issue) for issue in self.parent.pagure.search(
         query='user/{0}/requests/filed?status=all&created={1}..{2}'.format(
             self.user.login, self.options.since, self.options.until),
         pagination='pagination',
         result_field='requests')]
     self.stats = sorted(issues, key=lambda i: unicode(i))
Ejemplo n.º 42
0
Archivo: zammad.py Proyecto: psss/did
 def fetch(self):
     log.info("Searching for tickets updated by {0}".format(self.user))
     search = "article.from:\"{0}\" and article.created_at:[{1} TO {2}]".format(
         self.user.name, self.options.since, self.options.until)
     query = "tickets/search?query={0}".format(urllib.parse.quote(search))
     self.stats = [
         Ticket(ticket)
         for id, ticket in self.parent.zammad.search(query).items()
     ]
Ejemplo n.º 43
0
Archivo: bitly.py Proyecto: psss/did
 def fetch(self):
     '''
     Bit.ly API expect unix timestamps
     '''
     since = time.mktime(self.options.since.datetime.timetuple())
     until = time.mktime(self.options.until.datetime.timetuple())
     log.info("Searching for links saved by {0}".format(self.user))
     self.stats = self.parent.bitly.user_link_history(created_after=since,
                                                      created_before=until)
Ejemplo n.º 44
0
Archivo: bitly.py Proyecto: tosky/did
 def fetch(self):
     '''
     Bit.ly API expect unix timestamps
     '''
     since = time.mktime(self.options.since.datetime.timetuple())
     until = time.mktime(self.options.until.datetime.timetuple())
     log.info("Searching for links saved by {0}".format(self.user))
     self.stats = self.parent.bitly.user_link_history(created_after=since,
                                                      created_before=until)
Ejemplo n.º 45
0
 def fetch(self):
     log.info("Searching for issues resolved in {0} by {1}".format(
         self.parent.project, self.user))
     query = (
         "project = '{0}' AND assignee = '{1}' AND "
         "resolved >= {2} AND resolved <= {3}".format(
             self.parent.project, self.user.login,
             self.options.since, self.options.until))
     self.stats = Issue.search(query, stats=self)
Ejemplo n.º 46
0
Archivo: jira.py Proyecto: psss/did
 def fetch(self):
     log.info("Searching for issues created in {0} by {1}".format(
         self.parent.project, self.user))
     query = (
         "project = '{0}' AND creator = '{1}' AND "
         "created >= {2} AND created <= {3}".format(
             self.parent.project, self.user.email,
             self.options.since, self.options.until))
     self.stats = Issue.search(query, stats=self)
Ejemplo n.º 47
0
Archivo: bodhi.py Proyecto: psss/did
 def fetch(self):
     log.info('Searching for updates created by {0}'.format(self.user))
     self.stats = [
         Update(update) for update in self.parent.bodhi.search(
             query='updates/?user={0}&submitted_before={1}'
             '&submitted_since={2}'.format(self.user.login,
                                           self.options.until.date,
                                           self.options.since.date))
     ]
Ejemplo n.º 48
0
 def fetch(self):
     log.info(u"Searching for Issues closed by {0}".format(
         self.user))
     results = self.parent.gitlab.search(
         self.user.login, self.options.since, self.options.until,
         'Issue', 'closed')
     self.stats = [
         Issue(issue, self.parent.gitlab)
         for issue in results]
Ejemplo n.º 49
0
 def fetch(self):
     log.info(u"Searching for Merge requests closed by {0}".format(
         self.user))
     results = self.parent.gitlab.search(
         self.user.login, self.options.since, self.options.until,
         'MergeRequest', 'accepted')
     self.stats = [
         MergeRequest(mr, self.parent.gitlab)
         for mr in results]
Ejemplo n.º 50
0
    def fetch(self):
        log.info(u"Searching for bugs patched by {0}".format(self.user))
        query = {
            # Keywords field changed by the user
            "field0-0-0": "keywords",
            "type0-0-0": "changedby",
            "value0-0-0": self.user.email,
            # Patch keyword added
            "field0-1-0": "keywords",
            "type0-1-0": "changedto",
            "value0-1-0": "Patch",
            # Since date
            "field0-2-0": "keywords",
            "type0-2-0": "changedafter",
            "value0-2-0": str(self.options.since),
            # Until date
            "field0-3-0": "keywords",
            "type0-3-0": "changedbefore",
            "value0-3-0": str(self.options.until),
            }
        self.stats = [
            bug for bug in self.parent.bugzilla.search(
                query, options=self.options)
            if bug.patched(self.user)]

        # When user adds the Patch keyword when creating a bug, there is no
        # action in the bug's history from which this would be apparent. We
        # therefore need to check if there are any bugs reported by the user
        # which contain the Patch keyword but have no such action in their
        # history.
        query = {
            # Reported by user
            "f1": "reporter",
            "o1": "equals",
            "v1": self.user.email,
            # Since date
            "f2": "creation_ts",
            "o2": "greaterthan",
            "v2": str(self.options.since),
            # Until date
            "f3": "creation_ts",
            "o3": "lessthan",
            "v3": str(self.options.until),
            # Keywords contain Patch
            "f4": "keywords",
            "o4": "substring",
            "v4": "Patch",
            # The keyword was added when creating the bug
            "n5": "1",
            "f5": "keywords",
            "o5": "changedto",
            "v5": "Patch",
            }
        self.stats += [
            bug for bug in self.parent.bugzilla.search(
                query, options=self.options)]
Ejemplo n.º 51
0
 def fetch(self):
     log.info(u"Searching for MergeRequests commented by {0}".format(
         self.user))
     results = self.parent.gitlab.search(
         self.user.login, self.options.since, self.options.until,
         'Note', 'commented on')
     self.stats = [
         Note(issue, self.parent.gitlab)
         for issue in results
         if issue['note']['noteable_type'] == 'MergeRequest']
Ejemplo n.º 52
0
Archivo: trello.py Proyecto: happz/did
 def fetch(self):
     log.info(
         "Searching for cards updated in %s by %s",
         self.parent.option, self.user)
     actions = [
         act['data']['card']['name']
         for act in self.trello.get_actions(
             filters=self.filt,
             since=self.options.since.date,
             before=self.options.until.date)]
     self.stats = sorted(list(set(actions)))
Ejemplo n.º 53
0
    def search(self, query):
        """ Perform request tracker search """
        # Prepare the path
        log.debug("Query: {0}".format(query))
        path = self.url.path + '?Format=__id__+__Subject__'
        path += "&Order=ASC&OrderBy=id&Query=" + urllib.quote(query)

        # Get the tickets
        lines = self.get(path)
        log.info(u"Fetched tickets: {0}".format(len(lines)))
        return [self.parent.ticket(line, self.parent) for line in lines]
Ejemplo n.º 54
0
 def fetch(self):
     log.info("Searching for issues updated in {0} by {1}".format(
         self.parent.project, self.user))
     query = (
         "project = '{0}' AND "
         "updated >= {1} AND created <= {2}".format(
             self.parent.project,
             self.options.since, self.options.until))
     # Filter only issues commented by given user
     self.stats = [
         issue for issue in Issue.search(query, stats=self)
         if issue.updated(self.user, self.options)]
Ejemplo n.º 55
0
 def cases(self):
     """ All test cases created by the user """
     import nitrate
     if self._cases is None:
         log.info(u"Searching for cases created by {0}".format(self.user))
         self._cases = [
             case for case in nitrate.TestCase.search(
                 author__email=self.user.email,
                 create_date__gt=str(self.options.since),
                 create_date__lt=str(self.options.until))
             if case.status != nitrate.CaseStatus("DISABLED")]
     return self._cases
Ejemplo n.º 56
0
 def copies(self):
     """ All test case copies created by the user """
     import nitrate
     if self._copies is None:
         log.info(u"Searching for cases copied by {0}".format(self.user))
         self._copies = [
             case for case in nitrate.TestCase.search(
                 author__email=self.user.email,
                 create_date__gt=str(self.options.since),
                 create_date__lt=str(self.options.until),
                 tag__name=TEST_CASE_COPY_TAG)]
     return self._copies
Ejemplo n.º 57
0
Archivo: trello.py Proyecto: happz/did
 def fetch(self):
     log.info(
         "Searching for CheckItem completed in %s by %s",
         self.parent.option, self.user)
     actions = [
         "{0}: {1}".format(
             act['data']['card']['name'],
             act['data']['checkItem']['name'])
         for act in self.trello.get_actions(
             filters=self.filt,
             since=self.options.since.date,
             before=self.options.until.date)]
     self.stats = sorted(list(set(actions)))