mirror of
https://github.com/fuckpiracyshield/service.git
synced 2024-05-20 05:56:17 +02:00
53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
from piracyshield_service.base import BaseService
|
|
|
|
from piracyshield_component.exception import ApplicationException
|
|
|
|
from piracyshield_data_storage.ticket.item.storage import TicketItemStorage, TicketItemStorageGetException
|
|
|
|
from piracyshield_service.ticket.item.errors import TicketItemErrorCode, TicketItemErrorMessage
|
|
|
|
class TicketItemGetActiveService(BaseService):
|
|
|
|
"""
|
|
Returns all the blockable ticket items, grouped by genre.
|
|
This is currently used to build a cache.
|
|
"""
|
|
|
|
data_storage = None
|
|
|
|
def __init__(self):
|
|
"""
|
|
Inizialize logger and required modules.
|
|
"""
|
|
|
|
super().__init__()
|
|
|
|
self._prepare_modules()
|
|
|
|
def execute(self) -> list | Exception:
|
|
try:
|
|
response = self.data_storage.get_active()
|
|
|
|
document = next(response, None)
|
|
|
|
return document
|
|
|
|
except TicketItemStorageGetException as e:
|
|
self.logger.error(f'Could not get all the ticket items')
|
|
|
|
raise ApplicationException(TicketItemErrorCode.GENERIC, TicketItemErrorMessage.GENERIC, e)
|
|
|
|
def _schedule_task(self):
|
|
pass
|
|
|
|
def _validate_parameters(self):
|
|
pass
|
|
|
|
def _prepare_configs(self):
|
|
pass
|
|
|
|
def _prepare_modules(self):
|
|
self.data_storage = TicketItemStorage()
|