2022-08-25 17:03:56 +00:00
|
|
|
"""Jobs status"""
|
|
|
|
# pylint: disable=too-few-public-methods
|
|
|
|
import strawberry
|
2024-05-15 20:41:48 +00:00
|
|
|
from typing import List, Optional
|
|
|
|
|
|
|
|
from selfprivacy_api.jobs import Jobs
|
2022-08-25 17:03:56 +00:00
|
|
|
from selfprivacy_api.graphql.common_types.jobs import (
|
|
|
|
ApiJob,
|
|
|
|
get_api_job_by_id,
|
|
|
|
job_to_api_job,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2024-05-15 20:41:48 +00:00
|
|
|
def get_all_jobs() -> List[ApiJob]:
|
2024-05-22 11:04:37 +00:00
|
|
|
jobs = Jobs.get_jobs()
|
|
|
|
api_jobs = [job_to_api_job(job) for job in jobs]
|
|
|
|
assert api_jobs is not None
|
|
|
|
return api_jobs
|
2024-04-22 14:41:56 +00:00
|
|
|
|
|
|
|
|
2022-08-25 17:03:56 +00:00
|
|
|
@strawberry.type
|
|
|
|
class Job:
|
|
|
|
@strawberry.field
|
2024-05-15 20:41:48 +00:00
|
|
|
def get_jobs(self) -> List[ApiJob]:
|
2024-04-22 14:41:56 +00:00
|
|
|
return get_all_jobs()
|
2022-08-25 17:03:56 +00:00
|
|
|
|
|
|
|
@strawberry.field
|
2024-05-15 20:41:48 +00:00
|
|
|
def get_job(self, job_id: str) -> Optional[ApiJob]:
|
2022-08-25 17:03:56 +00:00
|
|
|
return get_api_job_by_id(job_id)
|