Changeset - 7d5dfe117d0f
[Not reviewed]
default
0 1 0
Mads Kiilerich - 6 years ago 2020-02-04 02:58:53
mads@kiilerich.com
Grafted from: 1a5ecd393d9c
summary: use calendar.monthrange instead of internal calendar.mday

Fix pytype warning:
No attribute 'mdays' on module 'calendar' [module-attr]

This also takes care of handling leap-years correctly. Not that it matters, but
very nice ...
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/summary.py
Show inline comments
 
@@ -163,25 +163,25 @@ class SummaryController(BaseRepoControll
 

	
 
    @LoginRequired(allow_default_user=True)
 
    @HasRepoPermissionLevelDecorator('read')
 
    def statistics(self, repo_name):
 
        if c.db_repo.enable_statistics:
 
            c.show_stats = True
 
            c.no_data_msg = _('No data ready yet')
 
        else:
 
            c.show_stats = False
 
            c.no_data_msg = _('Statistics are disabled for this repository')
 

	
 
        td = date.today() + timedelta(days=1)
 
        td_1m = td - timedelta(days=calendar.mdays[td.month])
 
        td_1m = td - timedelta(days=calendar.monthrange(td.year, td.month)[1])
 
        td_1y = td - timedelta(days=365)
 

	
 
        ts_min_m = mktime(td_1m.timetuple())
 
        ts_min_y = mktime(td_1y.timetuple())
 
        ts_max_y = mktime(td.timetuple())
 
        c.ts_min = ts_min_m
 
        c.ts_max = ts_max_y
 

	
 
        stats = Statistics.query() \
 
            .filter(Statistics.repository == c.db_repo) \
 
            .scalar()
 
        c.stats_percentage = 0
0 comments (0 inline, 0 general)