# Path: virtool/types.py



from asyncio import gather
from typing import Any, Dict, Optional
from virtool.db.transforms import apply_transforms
from virtool.jobs.utils import JobRights
from virtool.types import App
from virtool.users.db import AttachUserTransform
import virtool.utils
    4. Adds ``state`` and ``progress`` fields derived from the most recent ``status``
       entry in the job document.

    :param db: the application database object
    :param document: a document to process
    :return: a processed document

    """
    status = document["status"]

    last_update = status[-1]

    return await apply_transforms(
        virtool.utils.base_processor(
            {
                **document,
                "state": last_update["state"],
                "stage": last_update["stage"],
                "created_at": status[0]["timestamp"],
                "progress": status[-1]["progress"],
            }
        ),
        [AttachUserTransform(db)],
    )


async def delete(app: App, job_id: str):
    await app["db"].jobs.delete_one({"_id": job_id})



# Path: virtool/types.py



# Path: virtool/jobs/db.py
from asyncio import gather
from typing import Any, Dict, Optional
from virtool.db.transforms import apply_transforms
from virtool.jobs.utils import JobRights
from virtool.types import App
from virtool.users.db import AttachUserTransform
import virtool.utils

    4. Adds ``state`` and ``progress`` fields derived from the most recent ``status``
       entry in the job document.

    :param db: the application database object
    :param document: a document to process
    :return: a processed document

    """
    status = document["status"]

    last_update = status[-1]

    return await apply_transforms(
        virtool.utils.base_processor(
            {
                **document,
                "state": last_update["state"],
                "stage": last_update["stage"],
                "created_at": status[0]["timestamp"],
                "progress": status[-1]["progress"],
            }
        ),
        [AttachUserTransform(db)],
    )


async def delete(app: App, job_id: str):
    await app["db"].jobs.delete_one({"_id": job_id})



async def force_delete_jobs(app: App):