feat: fetch views manually and worker

This commit is contained in:
Artem Tsyrulnikov
2025-11-12 23:55:44 +03:00
parent 292bb0d49b
commit a48d5e67cb
28 changed files with 632 additions and 135 deletions

View File

@@ -33,9 +33,9 @@ async def get_views_history(
async def fetch_views(
purchase_id: uuid.UUID,
current_user: Annotated[JWTPayload, Depends(dependencies.get_current_user)],
) -> dto.FetchViewsOutput:
) -> dto.FetchViewsManuallyOutput:
"""Получить актуальные просмотры через Telegram API."""
input_data = dto.FetchViewsInput(
input_data = dto.FetchViewsInputManually(
purchase_id=purchase_id,
user_id=current_user.user_id,
)

View File

@@ -0,0 +1,15 @@
import logging
from typing import TYPE_CHECKING
from shared.worker_base import WorkerBase
from src import dependencies
if TYPE_CHECKING:
pass
log = logging.getLogger(__name__)
class FetchViewsWorker(WorkerBase):
async def _cycle_func(self) -> None:
await dependencies.get_usecase().run_views_worker_cycle(self.config.INTERVAL_SECONDS)