Moved inline imports to module level.
This commit is contained in:
@@ -8,6 +8,14 @@ from dataclasses import dataclass
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Optional, List
|
from typing import Optional, List
|
||||||
|
|
||||||
|
from .utils import (
|
||||||
|
MAX_INSTANCE_TITLE_LENGTH,
|
||||||
|
MAX_STREAM_TITLE_LENGTH,
|
||||||
|
MAX_TAG_LENGTH,
|
||||||
|
UNKNOWN_STATUS_THRESHOLD,
|
||||||
|
truncate,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class StreamStatus(Enum):
|
class StreamStatus(Enum):
|
||||||
"""Represents the status of a stream."""
|
"""Represents the status of a stream."""
|
||||||
@@ -31,8 +39,6 @@ class StreamState:
|
|||||||
@property
|
@property
|
||||||
def status(self) -> StreamStatus:
|
def status(self) -> StreamStatus:
|
||||||
"""Returns the stream status considering failure_counter."""
|
"""Returns the stream status considering failure_counter."""
|
||||||
from .utils import UNKNOWN_STATUS_THRESHOLD
|
|
||||||
|
|
||||||
if self.failure_counter > UNKNOWN_STATUS_THRESHOLD:
|
if self.failure_counter > UNKNOWN_STATUS_THRESHOLD:
|
||||||
return StreamStatus.UNKNOWN
|
return StreamStatus.UNKNOWN
|
||||||
elif self.last_connect_time is not None:
|
elif self.last_connect_time is not None:
|
||||||
@@ -49,8 +55,6 @@ class StreamState:
|
|||||||
:param domain: The stream domain
|
:param domain: The stream domain
|
||||||
:return: StreamState instance
|
:return: StreamState instance
|
||||||
"""
|
"""
|
||||||
from .utils import truncate, MAX_STREAM_TITLE_LENGTH
|
|
||||||
|
|
||||||
return cls(
|
return cls(
|
||||||
domain=domain,
|
domain=domain,
|
||||||
title=truncate(response.get("streamTitle", ""), MAX_STREAM_TITLE_LENGTH),
|
title=truncate(response.get("streamTitle", ""), MAX_STREAM_TITLE_LENGTH),
|
||||||
@@ -96,8 +100,6 @@ class StreamConfig:
|
|||||||
:param response: API response as a dictionary
|
:param response: API response as a dictionary
|
||||||
:return: StreamConfig instance
|
:return: StreamConfig instance
|
||||||
"""
|
"""
|
||||||
from .utils import truncate, MAX_INSTANCE_TITLE_LENGTH, MAX_TAG_LENGTH
|
|
||||||
|
|
||||||
# Truncate instance name to max length
|
# Truncate instance name to max length
|
||||||
name = truncate(response.get("name", ""), MAX_INSTANCE_TITLE_LENGTH)
|
name = truncate(response.get("name", ""), MAX_INSTANCE_TITLE_LENGTH)
|
||||||
|
|
||||||
|
|||||||
@@ -284,8 +284,6 @@ class StreamMonitor:
|
|||||||
await self.notification_service.send_cleanup_deletion(domain)
|
await self.notification_service.send_cleanup_deletion(domain)
|
||||||
|
|
||||||
# Delete all subscriptions for this domain
|
# Delete all subscriptions for this domain
|
||||||
from .database import SubscriptionRepository
|
|
||||||
|
|
||||||
subscription_repo = SubscriptionRepository(self.stream_repo.db)
|
subscription_repo = SubscriptionRepository(self.stream_repo.db)
|
||||||
deleted_count = await subscription_repo.delete_all_for_domain(domain)
|
deleted_count = await subscription_repo.delete_all_for_domain(domain)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user