progress action logic

This commit is contained in:
Robert 2024-02-28 18:09:12 +07:00
parent 12b57c8c0f
commit 86b0af1e17
No known key found for this signature in database
GPG Key ID: F631C7FD957D5F22
6 changed files with 47 additions and 0 deletions

View File

View File

@ -0,0 +1,9 @@
from abc import ABC, abstractmethod
from chain_service.database.models.progress_chain import BaseProgressAction
class BaseProgressActionService(ABC):
@abstractmethod
async def process(self, progress_action: BaseProgressAction):
pass

View File

@ -0,0 +1,8 @@
from .base import BaseProgressActionService
from chain_service.database.models.progress_chain import CommentProgressAction
class CommentProgressActionService(BaseProgressActionService):
async def process(self, progress_action: CommentProgressAction):
print("Comment service", progress_action)

View File

@ -0,0 +1,20 @@
from chain_service.database.models.progress_chain import BaseProgressAction
from .base import BaseProgressActionService
from .wait_progress_action import WaitProgressActionService
from .comment_progress_action import CommentProgressActionService
class ProgressActionServiceFactory:
def __call__(
self, progress_action: BaseProgressAction
) -> BaseProgressActionService:
match progress_action.action_type:
case "wait":
return WaitProgressActionService()
case "comment":
return CommentProgressActionService()

View File

@ -0,0 +1,10 @@
from .base import BaseProgressActionService
from chain_service.database.models.progress_chain import WaitProgressAction
import asyncio
class WaitProgressActionService(BaseProgressActionService):
async def process(self, progress_action: WaitProgressAction):
await asyncio.sleep(progress_action.wait_for)