Skip to content

Commit

Permalink
Conformidade com lint. #8
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleyvitor11000 committed Mar 13, 2023
1 parent e5e53b0 commit 6992587
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
17 changes: 9 additions & 8 deletions src/Scraper/application/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

from framework.infrastructure.connection_util import get_message_bus
from SearchEngine.domain.commands import GetComponentByUID
from SearchEngine.application.handlers import SE_COMMAND_HANDLER_MAPPER, SE_EVENT_HANDLER_MAPPER
from SearchEngine.application.handlers import (
SE_COMMAND_HANDLER_MAPPER,
SE_EVENT_HANDLER_MAPPER,
)
from SearchEngine.application.unit_of_work import SQLAlchemyUnitOfWork
from framework.domain.components import Component
from framework.application.handler import MessageHandler, Command
Expand All @@ -18,18 +21,15 @@
# Provisório. Mover para microsserviço de usuários.
class LowerPriceRegisteredHandler(MessageHandler):
def __call__(self, event: LowerPriceRegisteredEvent):
print('sending mail')
print("sending mail")
sender, passwd = mail, mail_passwd
recv_list = [sender]


message_bus = get_message_bus(
SE_EVENT_HANDLER_MAPPER,
SE_COMMAND_HANDLER_MAPPER,
SQLAlchemyUnitOfWork
SE_EVENT_HANDLER_MAPPER, SE_COMMAND_HANDLER_MAPPER, SQLAlchemyUnitOfWork
)

component : Component = message_bus.handle(
component: Component = message_bus.handle(
GetComponentByUID(event.component_uid)
)

Expand Down Expand Up @@ -72,6 +72,7 @@ def __call__(self, cmd: AddVolatileData):
with self.uow:
self.uow.repository.add(cmd.volatile_data)


CURL_COMMAND_HANDLER_MAPPER: Dict[Type[Command], Type[MessageHandler]] = {
AddCategoryURL: AddCategoryURLHandler,
GetCategoryURLByDomain: GetVolatileDataByDomainHandler,
Expand All @@ -85,5 +86,5 @@ def __call__(self, cmd: AddVolatileData):
}

VD_EVENT_HANDLER_MAPPER: Dict[Type[DomainEvent], Type[MessageHandler]] = {
LowerPriceRegisteredEvent : LowerPriceRegisteredHandler
LowerPriceRegisteredEvent: LowerPriceRegisteredHandler
}
2 changes: 1 addition & 1 deletion src/Scraper/domain/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

@dataclass
class LowerPriceRegisteredEvent(DomainEvent):
component_uid : UUID
component_uid: UUID
price: Money
6 changes: 5 additions & 1 deletion src/Scraper/infrastructure/SQL_alchemy_volatile_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ def _add(self, volatile_data: VolatileData):
db_volatile_data.cost + 0.1 < current_volatile_data.cost
and db_volatile_data.availability
):
volatile_data.events.append(LowerPriceRegisteredEvent(volatile_data.component_id, volatile_data.cost))
volatile_data.events.append(
LowerPriceRegisteredEvent(
volatile_data.component_id, volatile_data.cost
)
)
print(
f"preço reduzido de {current_volatile_data.cost} para {db_volatile_data.cost}."
)
Expand Down
4 changes: 3 additions & 1 deletion src/SearchEngine/infrastructure/message_bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@

__all__ = ["se_message_bus"]

se_message_bus = get_message_bus(SE_EVENT_HANDLER_MAPPER, SE_COMMAND_HANDLER_MAPPER, SQLAlchemyUnitOfWork)
se_message_bus = get_message_bus(
SE_EVENT_HANDLER_MAPPER, SE_COMMAND_HANDLER_MAPPER, SQLAlchemyUnitOfWork
)

0 comments on commit 6992587

Please sign in to comment.