feat: parser, refactoring
This commit is contained in:
@@ -41,9 +41,7 @@ from .target_channel.disconnect_target_chan import disconnect_target_chan
|
||||
from .target_channel.disconnect_target_chan_by_tg_id import disconnect_target_chan_by_tg_id
|
||||
from .target_channel.get_user_target_chans import get_user_target_chans
|
||||
from .target_channel.update_target_chan_permissions import update_target_chan_permissions
|
||||
from .views.fetch_views_manually import fetch_views_manually
|
||||
from .views.get_views_history import get_views_history
|
||||
from .views.run_views_worker_cycle import run_views_worker_cycle
|
||||
from .views.update_views_manually import update_views_manually
|
||||
|
||||
|
||||
@@ -66,8 +64,6 @@ class Database(typing.Protocol):
|
||||
self, user_id: UUID, channel_id: UUID | None = None, telegram_id: int | None = None
|
||||
) -> domain.TargetChannel | None: ...
|
||||
|
||||
async def create_target_channel(self, channel: domain.TargetChannel) -> domain.TargetChannel: ...
|
||||
|
||||
async def upsert_target_channel(self, channel: domain.TargetChannel) -> domain.TargetChannel: ...
|
||||
|
||||
async def get_user_target_channels(self, user_id: UUID) -> list[domain.TargetChannel]: ...
|
||||
@@ -123,8 +119,6 @@ class Database(typing.Protocol):
|
||||
|
||||
async def delete_placement(self, placement_id: UUID) -> None: ...
|
||||
|
||||
async def check_creative_in_use(self, creative_id: UUID) -> bool: ...
|
||||
|
||||
async def get_placement_by_invite_link(self, invite_link: str) -> domain.Placement | None: ...
|
||||
|
||||
async def get_subscriber(self, telegram_id: int) -> domain.Subscriber | None: ...
|
||||
@@ -161,8 +155,6 @@ class Database(typing.Protocol):
|
||||
to_date: datetime.datetime | None = None,
|
||||
) -> list[domain.PlacementViewsHistory]: ...
|
||||
|
||||
async def get_active_placements_with_urls(self) -> list[domain.Placement]: ... # Для worker
|
||||
|
||||
async def get_telegram_state(self, telegram_id: int) -> domain.TelegramState | None: ...
|
||||
|
||||
async def set_telegram_state(
|
||||
@@ -171,6 +163,17 @@ class Database(typing.Protocol):
|
||||
|
||||
async def clear_telegram_state(self, telegram_id: int) -> None: ...
|
||||
|
||||
# NATS-related methods for placement tracking
|
||||
async def get_placement_by_id(self, placement_id: UUID) -> domain.Placement | None: ...
|
||||
|
||||
async def update_placement_from_post_found(
|
||||
self, placement_id: UUID, ad_post_url: str, message_id: int, views_count: int
|
||||
) -> domain.Placement: ...
|
||||
|
||||
async def update_placement_from_post_deleted(self, placement_id: UUID) -> domain.Placement: ...
|
||||
|
||||
async def update_placement_views(self, placement_id: UUID, views_count: int) -> domain.Placement: ...
|
||||
|
||||
|
||||
class TelegramBotWriter(typing.Protocol):
|
||||
async def send_message(self, text: str, chat_id: int) -> None: ...
|
||||
@@ -188,10 +191,6 @@ class TelegramBotWriter(typing.Protocol):
|
||||
async def create_chat_invite_link(self, chat_id: int, requires_approval: bool = False) -> str: ...
|
||||
|
||||
|
||||
class TelegramParser(typing.Protocol):
|
||||
async def get_post_views(self, post_url: str) -> int | None: ...
|
||||
|
||||
|
||||
class JWTEncoder(typing.Protocol):
|
||||
def encode_access_token(self, user_id: UUID, telegram_id: int, username: str | None = None) -> str: ...
|
||||
|
||||
@@ -200,7 +199,6 @@ class JWTEncoder(typing.Protocol):
|
||||
class Usecase:
|
||||
database: Database
|
||||
telegram_bot: TelegramBotWriter
|
||||
telegram_parser: TelegramParser
|
||||
jwt_encoder: JWTEncoder
|
||||
|
||||
validate_login_token = validate_login_token
|
||||
@@ -232,8 +230,6 @@ class Usecase:
|
||||
delete_placement = delete_placement
|
||||
handle_subscription = handle_subscription
|
||||
handle_unsubscription = handle_unsubscription
|
||||
fetch_views = fetch_views_manually
|
||||
run_views_worker_cycle = run_views_worker_cycle
|
||||
get_views_history = get_views_history
|
||||
update_views_manually = update_views_manually
|
||||
get_placements_analytics = get_placements_analytics
|
||||
|
||||
Reference in New Issue
Block a user