Exemplo n.º 1
0
 def get_commits_action (self):
     weeknum = self.handler.request.query.get('weeknum', None)
     if weeknum != None:
         weeknum = int(weeknum)
         thisweek = utils.weeknum ()
         ago = thisweek - weeknum
         revs = db.Revision.select_revisions (branch=self.handler.record,
                                              weeknum=weeknum)
         cnt = revs.count()
         revs = list(revs[:20])
     else:
         revs = db.Revision.select_revisions (branch=self.handler.record,
                                              week_range=(utils.weeknum()-52,))
         cnt = revs.count()
         revs = list(revs[:10])
     if weeknum == None:
         title = (utils.gettext('Showing %i of %i commits:')
                  % (len(revs), cnt))
     elif ago == 0:
         title = (utils.gettext('Showing %i of %i commits from this week:')
                  % (len(revs), cnt))
     elif ago == 1:
         title = (utils.gettext('Showing %i of %i commits from last week:')
                  % (len(revs), cnt))
     else:
         title = (utils.gettext('Showing %i of %i commits from %i weeks ago:')
                  % (len(revs), cnt, ago))
     return self.get_commits_div (revs, title)
Exemplo n.º 2
0
    def get_tab (self):
        tab = html.Div ()
        of = db.OutputFile.select (type=u'graphs',
                                   ident=self.handler.record.ident,
                                   filename=u'commits-0.png')
        try:
            of = of[0] 
            graph = html.Graph.activity_graph (of,
                                               self.handler.record.pulse_url,
                                               'commits', utils.gettext ('%i commits'),
                                               'activity', {'action': 'commits'})
            tab.add_content (graph)
        except IndexError:
            pass

        revs = db.Revision.select_revisions (branch=self.handler.record,
                                             week_range=(utils.weeknum()-52,))
        cnt = revs.count()
        revs = list(revs[:10])
        title = (utils.gettext('Showing %i of %i commits:') % (len(revs), cnt))
        div = self.get_commits_div (revs, title)
        tab.add_content (div)
        return tab