org.sonar.db.purge.PurgeMapper.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sonar-db-dao Show documentation
Show all versions of sonar-db-dao Show documentation
Open source platform for continuous inspection of code quality
The newest version!
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd"> <mapper namespace="org.sonar.db.purge.PurgeMapper"> <select id="selectAnalysisIdsAndUuids" parameterType="map" resultType="IdUuidPair"> select s.id as id, s.uuid as uuid from snapshots s <where> <if test="islast != null"> and s.islast=#{islast} </if> <if test="notPurged != null and notPurged"> and (s.purge_status is null or s.purge_status=0) </if> <if test="componentUuid != null"> and s.component_uuid=#{componentUuid,jdbcType=VARCHAR} </if> <if test="status != null"> and s.status in <foreach item="s" index="index" collection="status" open="(" separator="," close=")">#{s}</foreach> </if> </where> </select> <select id="selectPurgeableAnalysesWithEvents" parameterType="String" resultType="PurgeableAnalysis"> select s.id as "analysisId", s.uuid as "analysisUuid", s.created_at as "date", ${_true} as "hasEvents", islast as "isLast", ve.name as "version" from snapshots s left outer join events ve on ve.analysis_uuid=s.uuid and ve.category='Version' where s.component_uuid=#{componentUuid,jdbcType=VARCHAR} and s.status='P' and exists(select e.id from events e where e.analysis_uuid=s.uuid) </select> <select id="selectPurgeableAnalysesWithoutEvents" parameterType="String" resultType="PurgeableAnalysis"> select s.id as "analysisId", s.uuid as "analysisUuid", s.created_at as "date", ${_false} as "hasEvents", islast as "isLast", NULL as "version" from snapshots s where s.component_uuid=#{componentUuid,jdbcType=VARCHAR} and s.status='P' and not exists(select e.id from events e where e.analysis_uuid=s.uuid) </select> <select id="selectStaleShortLivingBranchesAndPullRequests" parameterType="map" resultType="String"> select pb.uuid from project_branches pb where pb.project_uuid=#{mainBranchProjectUuid,jdbcType=VARCHAR} and (pb.branch_type='SHORT' or pb.branch_type='PULL_REQUEST') and pb.updated_at < #{toDate} </select> <select id="selectMetricIdsWithoutHistoricalData" resultType="long"> select id from metrics where delete_historical_data=${_true} </select> <select id="selectRootAndModulesOrSubviewsByProjectUuid" resultType="IdUuidPair" parameterType="String"> select p.id, p.uuid from projects p where ( p.project_uuid=#{rootUuid,jdbcType=VARCHAR} and p.scope = 'PRJ' and p.qualifier in ('SVW','BRC') ) or ( uuid=#{rootUuid,jdbcType=VARCHAR} and p.scope = 'PRJ' and p.qualifier in ('APP', 'VW','TRK') ) </select> <delete id="deleteAnalysisMeasures" parameterType="map"> delete from project_measures where analysis_uuid in <foreach collection="analysisUuids" open="(" close=")" item="analysisUuid" separator=","> #{analysisUuid,jdbcType=VARCHAR} </foreach> </delete> <delete id="fullDeleteComponentMeasures" parameterType="map"> delete from project_measures where component_uuid in <foreach collection="componentUuids" open="(" close=")" item="componentUuid" separator=","> #{componentUuid,jdbcType=VARCHAR} </foreach> </delete> <delete id="deleteComponentMeasures" parameterType="map"> delete from project_measures where analysis_uuid in <foreach collection="analysisUuids" open="(" close=")" item="analysisUuid" separator=","> #{analysisUuid,jdbcType=VARCHAR} </foreach> and component_uuid in <foreach collection="componentUuids" open="(" close=")" item="componentUuid" separator=","> #{componentUuid,jdbcType=VARCHAR} </foreach> </delete> <delete id="deleteAnalysisDuplications" parameterType="map"> delete from duplications_index where analysis_uuid in <foreach collection="analysisUuids" open="(" close=")" item="analysisUuid" separator=","> #{analysisUuid,jdbcType=VARCHAR} </foreach> </delete> <delete id="deleteAnalysisEvents" parameterType="map"> delete from events where analysis_uuid in <foreach collection="analysisUuids" open="(" close=")" item="analysisUuid" separator=","> #{analysisUuid,jdbcType=VARCHAR} </foreach> </delete> <delete id="deleteAnalyses" parameterType="map"> delete from snapshots where uuid in <foreach collection="analysisUuids" open="(" close=")" item="analysisUuid" separator=","> #{analysisUuid,jdbcType=VARCHAR} </foreach> </delete> <delete id="deleteAnalysisProperties" parameterType="map"> DELETE FROM analysis_properties WHERE snapshot_uuid IN <foreach collection="analysisUuids" open="(" close=")" item="analysisUuid" separator=","> #{analysisUuid,jdbcType=VARCHAR} </foreach> </delete> <delete id="deleteAnalysisWastedMeasures" parameterType="map"> delete from project_measures <where> analysis_uuid in <foreach collection="analysisUuids" open="(" close=")" item="analysisUuid" separator=","> #{analysisUuid} </foreach> and metric_id in <foreach collection="metricIds" open="(" item="metricId" separator="," close=")"> #{metricId,jdbcType=INTEGER} </foreach> </where> </delete> <update id="updatePurgeStatusToOne" parameterType="map"> update snapshots set purge_status = 1 where uuid in <foreach collection="analysisUuids" open="(" close=")" item="analysisUuid" separator=","> #{analysisUuid,jdbcType=VARCHAR} </foreach> </update> <update id="resolveComponentIssuesNotAlreadyResolved" parameterType="map"> update issues set status='CLOSED', resolution='REMOVED', updated_at=#{dateAsLong}, issue_close_date=#{dateAsLong}, issue_update_date=#{dateAsLong} where component_uuid in <foreach collection="componentUuids" open="(" close=")" item="componentUuid" separator=","> #{componentUuid,jdbcType=VARCHAR} </foreach> and resolution is null </update> <delete id="deleteProjectLinksByProjectUuid" parameterType="map"> delete from project_links where project_uuid = #{rootUuid,jdbcType=VARCHAR} </delete> <delete id="deletePropertiesByComponentIds" parameterType="map"> delete from properties where resource_id in <foreach collection="componentIds" open="(" close=")" item="componentId" separator=","> #{componentId} </foreach> </delete> <delete id="deleteComponentsByProjectUuid" parameterType="map"> delete from projects where project_uuid = #{rootUuid,jdbcType=VARCHAR} </delete> <delete id="deleteComponentsByUuids" parameterType="map"> delete from projects where uuid in <foreach collection="componentUuids" open="(" close=")" item="componentUuid" separator=","> #{componentUuid,jdbcType=VARCHAR} </foreach> </delete> <delete id="deleteGroupRolesByComponentId" parameterType="map"> delete from group_roles where resource_id = #{rootId,jdbcType=INTEGER} </delete> <delete id="deleteUserRolesByComponentId" parameterType="map"> delete from user_roles where resource_id = #{rootId,jdbcType=INTEGER} </delete> <delete id="deleteManualMeasuresByComponentUuids" parameterType="map"> delete from manual_measures where component_uuid in <foreach collection="componentUuids" open="(" close=")" item="componentUuid" separator=","> #{componentUuid,jdbcType=VARCHAR} </foreach> </delete> <delete id="deleteEventsByComponentUuid" parameterType="map"> delete from events where component_uuid = #{componentUuid,jdbcType=VARCHAR} </delete> <delete id="deleteIssueChangesByProjectUuid" parameterType="map"> delete from issue_changes ic where exists (select 1 from issues i where i.kee=ic.issue_key and i.project_uuid = #{projectUuid,jdbcType=VARCHAR}) </delete> <!-- Mssql --> <delete id="deleteIssueChangesByProjectUuid" databaseId="mssql" parameterType="map"> delete issue_changes from issue_changes inner join issues on issue_changes.issue_key=issues.kee where issues.project_uuid = #{projectUuid,jdbcType=VARCHAR} </delete> <!-- Mysql --> <delete id="deleteIssueChangesByProjectUuid" databaseId="mysql" parameterType="map"> delete ic from issue_changes as ic, issues as i where ic.issue_key=i.kee and i.component_uuid = #{projectUuid,jdbcType=VARCHAR} </delete> <delete id="deleteIssuesByProjectUuid" parameterType="map"> delete from issues where project_uuid = #{projectUuid,jdbcType=VARCHAR} </delete> <delete id="deleteFileSourcesByProjectUuid"> delete from file_sources where project_uuid=#{rootProjectUuid,jdbcType=VARCHAR} </delete> <delete id="deleteFileSourcesByFileUuid"> delete from file_sources where file_uuid in <foreach collection="fileUuids" open="(" close=")" item="fileUuid" separator=","> #{fileUuid,jdbcType=VARCHAR} </foreach> </delete> <select id="selectOldClosedIssueKeys" parameterType="map" resultType="String"> SELECT kee FROM issues WHERE project_uuid=#{projectUuid,jdbcType=VARCHAR} <choose> <when test="toDate == null"> AND issue_close_date IS NOT NULL </when> <otherwise> AND issue_close_date < #{toDate} </otherwise> </choose> </select> <delete id="deleteIssuesFromKeys" parameterType="map"> DELETE FROM issues WHERE kee IN <foreach collection="keys" open="(" close=")" item="key" separator=","> #{key,jdbcType=VARCHAR} </foreach> </delete> <delete id="deleteIssueChangesFromIssueKeys" parameterType="map"> DELETE FROM issue_changes WHERE issue_key IN <foreach collection="issueKeys" open="(" close=")" item="issueKey" separator=","> #{issueKey,jdbcType=VARCHAR} </foreach> </delete> <delete id="deleteCeScannerContextOfCeActivityByProjectUuid"> delete from ce_scanner_context where task_uuid in (select uuid from ce_activity where component_uuid=#{projectUuid,jdbcType=VARCHAR}) </delete> <delete id="deleteCeTaskCharacteristicsOfCeActivityByProjectUuid"> delete from ce_task_characteristics where task_uuid in (select uuid from ce_activity where component_uuid=#{projectUuid,jdbcType=VARCHAR}) </delete> <delete id="deleteCeTaskInputOfCeActivityByProjectUuid"> delete from ce_task_input where task_uuid in (select uuid from ce_activity where component_uuid=#{projectUuid,jdbcType=VARCHAR}) </delete> <delete id="deleteCeActivityByProjectUuid"> delete from ce_activity where component_uuid=#{projectUuid,jdbcType=VARCHAR} </delete> <delete id="deleteCeScannerContextOfCeQueueByProjectUuid"> delete from ce_scanner_context where task_uuid in (select uuid from ce_queue where component_uuid=#{projectUuid,jdbcType=VARCHAR}) </delete> <delete id="deleteCeTaskCharacteristicsOfCeQueueByProjectUuid"> delete from ce_task_characteristics where task_uuid in (select uuid from ce_queue where component_uuid=#{projectUuid,jdbcType=VARCHAR}) </delete> <delete id="deleteCeTaskInputOfCeQueueByProjectUuid"> delete from ce_task_input where task_uuid in (select uuid from ce_queue where component_uuid=#{projectUuid,jdbcType=VARCHAR}) </delete> <delete id="deleteCeQueueByProjectUuid"> delete from ce_queue where component_uuid=#{projectUuid,jdbcType=VARCHAR} </delete> <delete id="deleteWebhookDeliveriesByProjectUuid"> delete from webhook_deliveries where component_uuid=#{projectUuid,jdbcType=VARCHAR} </delete> <delete id="deleteProjectMappingsByProjectUuid"> delete from project_mappings where project_uuid=#{projectUuid,jdbcType=VARCHAR} </delete> <delete id="deleteBranchByUuid"> delete from project_branches where uuid=#{uuid,jdbcType=VARCHAR} </delete> <delete id="deleteLiveMeasuresByProjectUuid"> delete from live_measures where project_uuid = #{projectUuid,jdbcType=VARCHAR} </delete> </mapper>