"""
Job Store
In-Memory Store für Generation Jobs
(Später: Redis Backend)
"""

from typing import Dict, Optional
from app.models.generation_job import GenerationJob


class JobStore:
    """In-Memory Job Store"""

    def __init__(self):
        self._jobs: Dict[str, GenerationJob] = {}

    def save(self, job: GenerationJob):
        """Save Job"""
        self._jobs[job.job_id] = job

    def get(self, job_id: str) -> Optional[GenerationJob]:
        """Get Job by ID"""
        return self._jobs.get(job_id)

    def delete(self, job_id: str):
        """Delete Job"""
        if job_id in self._jobs:
            del self._jobs[job_id]

    def list_all(self) -> list[GenerationJob]:
        """List all Jobs"""
        return list(self._jobs.values())

    def clear(self):
        """Clear all Jobs"""
        self._jobs.clear()
