Merge remote-tracking branch 'gitea/main' into codex/iwooos-wazuh-boundary-guard-20260624
Some checks failed
Code Review / ai-code-review (push) Successful in 13s
CD Pipeline / tests (push) Successful in 1m37s
CD Pipeline / build-and-deploy (push) Successful in 5m5s
CD Pipeline / post-deploy-checks (push) Successful in 3m51s
Ansible / Reboot Recovery Contract / validate (push) Has been cancelled

This commit is contained in:
ogt
2026-06-25 11:11:21 +08:00
2 changed files with 87 additions and 12 deletions

View File

@@ -2052,7 +2052,25 @@ async def _fetch_source_review_decisions_by_work_item(
result = await db.execute(
text("""
SELECT DISTINCT ON (context->>'work_item_id')
WITH ranked AS (
SELECT
id,
incident_id,
actor,
action_detail,
success,
context,
created_at,
ROW_NUMBER() OVER (
PARTITION BY context->>'work_item_id'
ORDER BY created_at DESC
) AS rn
FROM alert_operation_log
WHERE actor = :actor
AND context->>'schema_version' = :schema_version
AND COALESCE(context->>'project_id', :project_id) = :project_id
)
SELECT
id,
incident_id,
actor,
@@ -2060,11 +2078,9 @@ async def _fetch_source_review_decisions_by_work_item(
success,
context,
created_at
FROM alert_operation_log
WHERE actor = :actor
AND context->>'schema_version' = :schema_version
AND COALESCE(context->>'project_id', :project_id) = :project_id
ORDER BY context->>'work_item_id', created_at DESC
FROM ranked
WHERE rn = 1
ORDER BY created_at DESC
LIMIT :limit
"""),
{
@@ -2094,7 +2110,25 @@ async def _fetch_source_applies_by_work_item(
result = await db.execute(
text("""
SELECT DISTINCT ON (context->>'work_item_id')
WITH ranked AS (
SELECT
id,
incident_id,
actor,
action_detail,
success,
context,
created_at,
ROW_NUMBER() OVER (
PARTITION BY context->>'work_item_id'
ORDER BY created_at DESC
) AS rn
FROM alert_operation_log
WHERE actor = :actor
AND context->>'schema_version' = :schema_version
AND COALESCE(context->>'project_id', :project_id) = :project_id
)
SELECT
id,
incident_id,
actor,
@@ -2102,11 +2136,9 @@ async def _fetch_source_applies_by_work_item(
success,
context,
created_at
FROM alert_operation_log
WHERE actor = :actor
AND context->>'schema_version' = :schema_version
AND COALESCE(context->>'project_id', :project_id) = :project_id
ORDER BY context->>'work_item_id', created_at DESC
FROM ranked
WHERE rn = 1
ORDER BY created_at DESC
LIMIT :limit
"""),
{