from typing import Optional

from thestage.entities.project_inference_simulator import ProjectInferenceSimulatorEntity
from thestage.services.abstract_mapper import AbstractMapper
from thestage.services.project.dto.inference_simulator_dto import InferenceSimulatorDto


class ProjectInferenceSimulatorMapper(AbstractMapper):

    def build_entity(self, item: InferenceSimulatorDto) -> Optional[ProjectInferenceSimulatorEntity]:
        if not item:
            return None

        return ProjectInferenceSimulatorEntity(
            id=item.id,
            title=item.title or '',
            status=item.status or '',
            url=item.url or '',
            started_at=item.created_at or '',
            finished_at=item.updated_at or ''
        )
