время в топе и тэги креативов
This commit is contained in:
@@ -4,6 +4,7 @@ from dataclasses import dataclass
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from fastapi import HTTPException, status
|
||||
from tortoise import timezone
|
||||
|
||||
from src import domain, dto
|
||||
|
||||
@@ -278,25 +279,25 @@ async def get_projects_analytics(
|
||||
|
||||
# Определяем дату для period_label (берем первую дату периода)
|
||||
if input.grouping == dto.DateGrouping.DAY:
|
||||
period_dt = datetime.datetime.strptime(period_key, '%Y-%m-%d')
|
||||
period_dt = datetime.datetime.strptime(period_key, '%Y-%m-%d').replace(tzinfo=datetime.UTC)
|
||||
elif input.grouping == dto.DateGrouping.WEEK:
|
||||
# ISO week format: YYYY-Www
|
||||
year, week_str = period_key.split('-W')
|
||||
week = int(week_str)
|
||||
# Находим первый день недели (понедельник) для данной ISO недели
|
||||
jan4 = datetime.datetime(int(year), 1, 4)
|
||||
jan4 = datetime.datetime(int(year), 1, 4, tzinfo=datetime.UTC)
|
||||
jan4_weekday = jan4.weekday() # 0=Monday, 6=Sunday
|
||||
days_since_monday = (jan4_weekday + 1) % 7
|
||||
jan4_monday = jan4 - datetime.timedelta(days=days_since_monday)
|
||||
period_dt = jan4_monday + datetime.timedelta(weeks=week - 1)
|
||||
elif input.grouping == dto.DateGrouping.MONTH:
|
||||
period_dt = datetime.datetime.strptime(period_key, '%Y-%m')
|
||||
period_dt = datetime.datetime.strptime(period_key, '%Y-%m').replace(tzinfo=datetime.UTC)
|
||||
elif input.grouping == dto.DateGrouping.QUARTER:
|
||||
year, quarter = period_key.split('-Q')
|
||||
month = (int(quarter) - 1) * 3 + 1
|
||||
period_dt = datetime.datetime(int(year), month, 1)
|
||||
period_dt = datetime.datetime(int(year), month, 1, tzinfo=datetime.UTC)
|
||||
else:
|
||||
period_dt = datetime.datetime.now()
|
||||
period_dt = timezone.now()
|
||||
|
||||
period_label = _format_period_label(period_dt, input.grouping)
|
||||
metrics = _calculate_metrics(pd, input.metrics, hide_subscriptions)
|
||||
|
||||
Reference in New Issue
Block a user