Merge branch 'hotfix/statistic' into 'develop'

fix bug and fix months display

See merge request 2020-2021/online/s101/group-02/access_controller!99
This commit is contained in:
Кравченко Артем 2021-05-29 21:57:00 +00:00
commit b2ccee4f28
2 changed files with 5 additions and 5 deletions

View File

@ -151,17 +151,16 @@ class StatisticData:
return stat return stat
new_stat = {} new_stat = {}
if self.interval == 'months': if self.interval == 'months':
# Переделываем ключи под формат('началоесяца - конец_месяца')
for key, value in stat.items(): for key, value in stat.items():
current_month_start = max(self.start_date, date(year=key.year, month=key.month, day=1)) current_month_start = max(self.start_date, date(year=key.year, month=key.month, day=1))
current_month_end = min(self.end_date, last_day_of_month(date(year=key.year, month=key.month, day=1))) current_month_end = min(self.end_date, last_day_of_month(date(year=key.year, month=key.month, day=1)))
index = ' - '.join([str(current_month_start), str(current_month_end)]) index = (current_month_start, current_month_end)
if new_stat.get(index): if new_stat.get(index):
new_stat[index] += value new_stat[index] += value
else: else:
new_stat[index] = value new_stat[index] = value
elif self.interval == 'days': elif self.interval == 'days':
new_stat = stat # статистика изначально в днях new_stat = stat
return new_stat return new_stat
def check_time(self) -> bool: def check_time(self) -> bool:
@ -240,7 +239,8 @@ class StatisticData:
:param last_log: Последний лог изменения роли, в результате которого пользователь назначен инженером. :param last_log: Последний лог изменения роли, в результате которого пользователь назначен инженером.
:return: Дополняет статистику работы :return: Дополняет статистику работы
""" """
self.fill_daterange(last_log.change_time.date() + timedelta(days=1), self.end_date + timedelta(days=1)) self.fill_daterange(last_log.change_time.date() + timedelta(days=1),
min(self.end_date, timezone.now().date()) + timedelta(days=1))
if last_log.change_time.date() == timezone.now().date(): if last_log.change_time.date() == timezone.now().date():
self.statistic[last_log.change_time.date()] += ( self.statistic[last_log.change_time.date()] += (
get_timedelta(None, timezone.now().time()) - get_timedelta(last_log) get_timedelta(None, timezone.now().time()) - get_timedelta(last_log)

View File

@ -91,7 +91,7 @@
{% if interval == 'days' %} {% if interval == 'days' %}
<td scope="col">{{ date | date:'d.m' }}</td> <td scope="col">{{ date | date:'d.m' }}</td>
{% else %} {% else %}
<td scope="col">{{ date.1 | date:'F' }}</td> <td scope="col">{{ date.0 | date:'d F' }} - {{ date.1 | date:'d F' }}</td>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</tr> </tr>