# Code generated by sqlc. DO NOT EDIT.
# versions:
#   sqlc v1.29.0
# source: update_hype_cron_job_run_status.sql
import dataclasses
from typing import Any

import sqlalchemy
import sqlalchemy.ext.asyncio

from . import models


UPDATE_HYPE_CRON_JOB_RUN_STATUS = """-- name: update_hype_cron_job_run_status \\:exec
UPDATE hype_cron_job_run_details
SET status = :p1\\:\\:hype_cron_job_status_enum,
    start_time = CASE WHEN start_time IS NULL THEN NOW() ELSE start_time END,
    end_time = CASE WHEN :p1 IN ('SUCCESS', 'FAILED') THEN NOW() ELSE end_time END
WHERE runid = :p2
"""


@dataclasses.dataclass()
class UpdateHypeCronJobRunStatusParams:
    status: Any
    runid: int


class Querier:
    def __init__(self, conn: sqlalchemy.engine.Connection):
        self._conn = conn

    def update_hype_cron_job_run_status(self, arg: UpdateHypeCronJobRunStatusParams) -> None:
        self._conn.execute(sqlalchemy.text(UPDATE_HYPE_CRON_JOB_RUN_STATUS), {"p1": arg.status, "p2": arg.runid})


class AsyncQuerier:
    def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
        self._conn = conn

    async def update_hype_cron_job_run_status(self, arg: UpdateHypeCronJobRunStatusParams) -> None:
        await self._conn.execute(sqlalchemy.text(UPDATE_HYPE_CRON_JOB_RUN_STATUS), {"p1": arg.status, "p2": arg.runid})
