cast(case when csc.task_uuid is null then 0 else 1 end as bit) as hasScannerContext case when csc.task_uuid is null then 0 else 1 end as hasScannerContext csc.task_uuid is not null as hasScannerContext ca.uuid, ca.node_name as nodeName, ca.task_type as taskType, ca.component_uuid as componentUuid, ca.entity_uuid as entityUuid, ca.analysis_uuid as analysisUuid, ca.status as status, ca.submitter_uuid as submitterUuid, ca.submitted_at as submittedAt, ca.worker_uuid as workerUuid, ca.started_at as startedAt, ca.executed_at as executedAt, ca.created_at as createdAt, ca.updated_at as updatedAt, ca.is_last as isLast, ca.is_last_key as isLastKey, ca.main_is_last as mainIsLast, ca.main_is_last_key as mainIsLastKey, ca.execution_time_ms as executionTimeMs, ca.error_message as errorMessage, ca.error_type as errorType, ctm.uuid as ctm_uuid, ctm.task_uuid as ctm_taskUuid, ctm.message as ctm_message, ctm.message_type as ctm_type, ctm.created_at as ctm_createdAt , from ce_activity ca left outer join ce_task_message ctm on ca.uuid = ctm.task_uuid left outer join ce_scanner_context csc on csc.task_uuid = ca.uuid order by ca.created_at desc, uuid desc select ca.uuid from ce_activity ca and ca.main_is_last=${_true} and ca.entity_uuid in #{cUuid,jdbcType=VARCHAR} and ca.status in #{status,jdbcType=VARCHAR} and ca.error_type in #{errorType,jdbcType=VARCHAR} and ca.task_type=#{query.type,jdbcType=VARCHAR} and ca.submitted_at >= #{query.minSubmittedAt,jdbcType=BIGINT} and ca.executed_at <= #{query.maxExecutedAt,jdbcType=BIGINT} and ca.executed_at >= #{query.minExecutedAt,jdbcType=BIGINT} insert into ce_activity ( uuid, node_name, component_uuid, entity_uuid, analysis_uuid, status, task_type, is_last, is_last_key, main_is_last, main_is_last_key, submitter_uuid, submitted_at, worker_uuid, execution_count, started_at, executed_at, created_at, updated_at, execution_time_ms, error_message, error_stacktrace, error_type ) values ( #{uuid,jdbcType=VARCHAR}, #{nodeName,jdbcType=VARCHAR}, #{componentUuid,jdbcType=VARCHAR}, #{entityUuid,jdbcType=VARCHAR}, #{analysisUuid,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{taskType,jdbcType=VARCHAR}, #{isLast,jdbcType=BOOLEAN}, #{isLastKey,jdbcType=VARCHAR}, #{mainIsLast,jdbcType=BOOLEAN}, #{mainIsLastKey,jdbcType=VARCHAR}, #{submitterUuid,jdbcType=VARCHAR}, #{submittedAt,jdbcType=BIGINT}, #{workerUuid,jdbcType=VARCHAR}, 0, #{startedAt,jdbcType=BIGINT}, #{executedAt,jdbcType=BIGINT}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}, #{executionTimeMs,jdbcType=BIGINT}, #{errorMessage,jdbcType=VARCHAR}, #{errorStacktrace,jdbcType=CLOB}, #{errorType,jdbcType=VARCHAR} ) update ce_activity set is_last=${_false}, updated_at=#{updatedAt,jdbcType=BIGINT} where is_last=${_true} and is_last_key=#{isLastKey,jdbcType=VARCHAR} update ce_activity set main_is_last=${_false}, updated_at=#{updatedAt,jdbcType=BIGINT} where main_is_last=${_true} and main_is_last_key=#{mainIsLastKey,jdbcType=VARCHAR} delete from ce_activity where uuid in #{uuid,jdbcType=VARCHAR} select case when exists ( select ca.uuid from ce_activity ca inner join project_branches pb on ca.component_uuid = pb.uuid where ca.task_type = 'ISSUE_SYNC' and ca.status in ('FAILED', 'CANCELED') and pb.need_issue_sync = ${_true} ) then 1 else 0 end