#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2023/5/27 22:06 # @Author : old tom # @File : metadata_task_dao.py # @Project : futool-tiny-datahub # @Desc : from common.fudb.connectors.connector_factory import ConnFactory from common.fudb.dbapis.fu_dao import BaseDao class MetaTaskDao(BaseDao): def __init__(self, connector: ConnFactory): super().__init__(connector) def create_task(self, compare_id, version_code_1, version_code_2, source_id_1, source_id_2, compare_task_type): sql = f"insert into metadata_compare_task (compare_id,compare_task_type,source_id_1,source_id_2,version_code_1,version_code_2)" \ f" values ('{compare_id}','{compare_task_type}','{source_id_1}','{source_id_2}',{version_code_1},{version_code_2})" return self.execute_update(sql) > 0 def finish_task(self, compare_id): sql = f"update metadata_compare_task set has_finish='Y',finish_time=now() where compare_id='{compare_id}'" return self.execute_update(sql) > 0 def check_task_status(self, compare_id): """ 校验任务是否完成 :param compare_id: :return: """ sql = f"select has_finish,to_char(created_time,'yyyy-MM-dd hh24:mi:ss') from metadata_compare_task where compare_id='{compare_id}'" return self.query_one(sql) def task_exists(self, compare_id): rt = self.query_one(f"select count(1) from metadata_compare_task where compare_id='{compare_id}'")[0] return rt > 0