from interactor import BaseInteractor
from model.log import LogEntry


class EventInteractor(BaseInteractor):
    def execute(self, log_entry):
        # type: (LogEntry) -> None

        if log_entry is None:
            return

        if log_entry.event_type == "HVCOMPSTATE":
            return

        if not log_entry.business_period:
            return

        event_to_dispatch = self.log_repository.insert_entry(log_entry)
        self.event_dispatcher.dispatch_event(event_to_dispatch)
