From b817ba029ffde18e09ed6b4f994faec10737e9bb Mon Sep 17 00:00:00 2001 From: lukasz-jarocki-sonarsource Date: Thu, 28 Mar 2024 16:40:24 +0100 Subject: [PATCH] SONAR-19324 rely on project_branches instead of components when calling api/projects/search endpoint --- .../org/sonar/db/component/SnapshotMapper.xml | 74 +++++++------------ 1 file changed, 28 insertions(+), 46 deletions(-) diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/SnapshotMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/SnapshotMapper.xml index f64fbfe2139..a35d3a97399 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/SnapshotMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/SnapshotMapper.xml @@ -54,52 +54,34 @@ and coalesce(pb.project_uuid, p.branch_uuid) = #{projectUuid,jdbcType=VARCHAR} - + select + pb.project_uuid as project_uuid, + max(s.created_at) as last_analysis_date + from + snapshots s + inner join project_branches pb on + pb.uuid = s.root_component_uuid + where + s.islast = ${_true} and pb.project_uuid in + + #{projectUuid,jdbcType=VARCHAR} + + group by pb.project_uuid + union + select + p.uuid as project_uuid, + max(s.created_at) as last_analysis_date + from + snapshots s + inner join portfolios p on + p.uuid = s.root_component_uuid + where + s.islast = ${_true} and p.uuid in + + #{projectUuid,jdbcType=VARCHAR} + + group by p.uuid