Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Отмена изменений в расчете added_external_users #658

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/api/services/analytics.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import timedelta

from src.api.constants import DAYS_NUMBER_FOR_USERS_STATISTIC
from src.core.db.repository import ExternalSiteUserRepository, UnsubscribeReasonRepository, UserRepository
from src.core.db.repository import UnsubscribeReasonRepository, UserRepository


class AnalyticsService:
Expand All @@ -11,11 +11,9 @@ def __init__(
self,
user_repository: UserRepository,
unsubscribe_reason_repository: UnsubscribeReasonRepository,
site_user_repository: ExternalSiteUserRepository,
) -> None:
self._user_repository: UserRepository = user_repository
self._unsubscribe_reason_repository: UnsubscribeReasonRepository = unsubscribe_reason_repository
self._site_user_repository: ExternalSiteUserRepository = site_user_repository

async def get_user_number(self) -> None:
return await self._user_repository.count_all()
Expand All @@ -31,8 +29,8 @@ async def get_added_users_statistic(self, date_limit) -> dict[str, int]:

async def get_added_external_users_statistic(self, date_limit) -> dict[str, int]:
date_begin = date_limit - timedelta(days=DAYS_NUMBER_FOR_USERS_STATISTIC - 1)
added_external_users = await self._site_user_repository.get_statistics_by_days(
date_begin, date_limit, "created_at"
added_external_users = await self._user_repository.get_statistics_by_days(
date_begin, date_limit, "external_signup_date"
)
return added_external_users

Expand Down
1 change: 0 additions & 1 deletion src/core/depends/api_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class APIServicesContainer(containers.DeclarativeContainer):
AnalyticsService,
user_repository=repositories.user_repository,
unsubscribe_reason_repository=repositories.unsubscribe_reason_repository,
site_user_repository=repositories.site_user_repository,
)
health_check_service = providers.Factory(
HealthCheckService,
Expand Down