from .models import ImageSession, ImageState, ProcessingJob


def image_session_get(*, session_id):
    return ImageSession.objects.filter(id=session_id).first()


def processing_job_get(*, job_id):
    return ProcessingJob.objects.filter(id=job_id).first()


def image_state_get(*, state_id):
    return ImageState.objects.select_related("session", "parent").filter(id=state_id).first()


def image_states_list(*, session_id):
    return ImageState.objects.select_related("parent").filter(session_id=session_id).order_by("sequence", "created_at")
