Exemplo n.º 1
0
 def get_context_data(self, **kwargs):
     context = super(BugmailStatsView, self).get_context_data(**kwargs)
     json_stats = cache.get(self.cache_key)
     if not json_stats:
         wks_ago = (now() - timedelta(days=14)).date()
         stats = BugmailStat.objects.stats_for_range(wks_ago)
         stats_dict = {
             BugmailStat.TOTAL: defaultdict(int),
             BugmailStat.USED: defaultdict(int),
         }
         for s in stats:
             stats_dict[s.stat_type][date_to_js(s.date)] += s.count
         all_stats = {
             'total': [],
             'used': [],
             'x_axis': [],
         }
         stats_total = stats_dict[BugmailStat.TOTAL]
         stats_used = stats_dict[BugmailStat.USED]
         for d in date_range(wks_ago):
             d = date_to_js(d)
             all_stats['x_axis'].append(d)
             all_stats['total'].append([d, stats_total[d]])
             all_stats['used'].append([d, stats_used[d]])
         json_stats = json.dumps(all_stats)
         cache.set(self.cache_key, json_stats, 1800)  # 30 minutes
     context['stats'] = json_stats
     return context
Exemplo n.º 2
0
    def get_context_data(self, **kwargs):
        context = super(BugmailStatsView, self).get_context_data(**kwargs)
        no_cache = self.request.META.get('HTTP_CACHE_CONTROL') == 'no-cache'
        json_stats = None if no_cache else cache.get(self.cache_key)

        if not json_stats:
            wks_ago = (now() - timedelta(days=14)).date()
            stats = BugmailStat.objects.stats_for_range(wks_ago)
            stats_dict = {
                BugmailStat.TOTAL: defaultdict(int),
                BugmailStat.USED: defaultdict(int),
            }
            for s in stats:
                stats_dict[s.stat_type][date_to_js(s.date)] += s.count
            all_stats = {
                'total': [],
                'used': [],
                'x_axis': [],
            }
            stats_total = stats_dict[BugmailStat.TOTAL]
            stats_used = stats_dict[BugmailStat.USED]
            for d in date_range(wks_ago):
                d = date_to_js(d)
                all_stats['x_axis'].append(d)
                all_stats['total'].append([d, stats_total[d]])
                all_stats['used'].append([d, stats_used[d]])
            json_stats = json.dumps(all_stats)
            cache.set(self.cache_key, json_stats, 1800)  # 30 minutes
        context['stats'] = json_stats
        return context
Exemplo n.º 3
0
 def get_burndown_axis(self):
     """Return a list of epoch dates between sprint start and end
     inclusive"""
     return [
         date_to_js(cdate)
         for cdate in date_range(self.start_date, self.end_date)
     ]
Exemplo n.º 4
0
 def get_burndown(self):
     """Return a list of total point values per day of sprint"""
     today = now().date()
     sdate = self.start_date
     edate = self.end_date if self.end_date < today else today
     if sdate > today:
         return []
     tseries = []
     for cdate in date_range(sdate, edate):
         cpoints = 0
         for bug in self.get_bugs():
             cpoints += bug.points_for_date(cdate)
         tseries.append([date_to_js(cdate), cpoints])
     return tseries
Exemplo n.º 5
0
 def get_burndown(self):
     """Return a list of total point values per day of sprint"""
     today = now().date()
     sdate = self.start_date
     edate = self.end_date if self.end_date < today else today
     if sdate > today:
         return []
     tseries = []
     for cdate in date_range(sdate, edate):
         cpoints = 0
         for bug in self.get_bugs():
             cpoints += bug.points_for_date(cdate)
         tseries.append([date_to_js(cdate), cpoints])
     return tseries
Exemplo n.º 6
0
 def get_burndown_axis(self):
     """Return a list of epoch dates between sprint start and end
     inclusive"""
     return [date_to_js(cdate) for cdate in
             date_range(self.start_date, self.end_date)]