mirror of
https://github.com/kurbezz/discord-bot.git
synced 2025-12-06 15:15:37 +01:00
Fix
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from .sync import syncronize
|
||||
from .sync import syncronize, syncronize_all
|
||||
|
||||
|
||||
__all__ = [
|
||||
"syncronize",
|
||||
"syncronize_all",
|
||||
]
|
||||
|
||||
@@ -6,13 +6,24 @@ from applications.schedule_sync.synchronizer import syncronize as syncronize_int
|
||||
|
||||
@activity.defn
|
||||
async def syncronize(twitch_id: int):
|
||||
streamer = await StreamerConfigRepository.get_by_twitch_id(twitch_id)
|
||||
|
||||
if streamer.integrations.discord is None:
|
||||
return
|
||||
|
||||
try:
|
||||
streamer = await StreamerConfigRepository.get_by_twitch_id(twitch_id)
|
||||
|
||||
if streamer.integrations.discord is None:
|
||||
return
|
||||
|
||||
await syncronize_internal(streamer.twitch, streamer.integrations.discord.guild_id)
|
||||
except Exception as e:
|
||||
activity.logger.error(f"Error during synchronization: {e}")
|
||||
raise e
|
||||
|
||||
|
||||
@activity.defn
|
||||
async def syncronize_all():
|
||||
streamers = await StreamerConfigRepository().all()
|
||||
|
||||
for streamer in streamers:
|
||||
if streamer.integrations.discord is None:
|
||||
continue
|
||||
|
||||
await syncronize(streamer.twitch.id)
|
||||
|
||||
@@ -3,8 +3,7 @@ from datetime import timedelta
|
||||
from temporalio import workflow
|
||||
from temporalio.client import Schedule, ScheduleActionStartWorkflow, ScheduleSpec, ScheduleIntervalSpec
|
||||
|
||||
from applications.common.repositories.streamers import StreamerConfigRepository
|
||||
from applications.schedule_sync.activities import syncronize
|
||||
from applications.schedule_sync.activities import syncronize_all
|
||||
from applications.temporal_worker.queues import MAIN_QUEUE
|
||||
|
||||
|
||||
@@ -28,15 +27,8 @@ class ScheduleSyncWorkflow:
|
||||
|
||||
@workflow.run
|
||||
async def run(self):
|
||||
streamers = await StreamerConfigRepository().all()
|
||||
|
||||
for streamer in streamers:
|
||||
if streamer.integrations.discord is None:
|
||||
continue
|
||||
|
||||
await workflow.start_activity(
|
||||
syncronize,
|
||||
streamer.twitch.id,
|
||||
task_queue=MAIN_QUEUE,
|
||||
schedule_to_close_timeout=timedelta(minutes=5),
|
||||
)
|
||||
await workflow.execute_activity(
|
||||
syncronize_all,
|
||||
task_queue=MAIN_QUEUE,
|
||||
schedule_to_close_timeout=timedelta(minutes=5),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user