- <?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.issue.IssueMapper">
-
- <sql id="issueColumns">
- i.kee as kee,
- i.rule_uuid as ruleUuid,
- i.severity as severity,
- i.manual_severity as manualSeverity,
- i.message as message,
- i.message_formattings as messageFormattings,
- i.line as line,
- i.locations as locations,
- i.gap as gap,
- i.effort as effort,
- i.status as status,
- i.resolution as resolution,
- i.checksum as checksum,
- i.assignee as assigneeUuid,
- i.author_login as authorLogin,
- i.tags as tagsString,
- i.rule_description_context_key as ruleDescriptionContextKey,
- i.issue_creation_date as issueCreationTime,
- i.issue_update_date as issueUpdateTime,
- i.issue_close_date as issueCloseTime,
- i.created_at as createdAt,
- i.updated_at as updatedAt,
- r.is_external as "isExternal",
- r.plugin_rule_key as ruleKey,
- r.plugin_name as ruleRepo,
- r.language as language,
- r.security_standards as securityStandards,
- i.clean_code_attribute as cleanCodeAttribute,
- r.clean_code_attribute as ruleCleanCodeAttribute,
- p.kee as componentKey,
- i.component_uuid as componentUuid,
- p.path as filePath,
- root.kee as projectKey,
- i.project_uuid as projectUuid,
- i.issue_type as type,
- i.quick_fix_available as quickFixAvailable,
- i.code_variants as codeVariantsString,
- <include refid="issueImpactsColumns"/>
- <include refid="ruleDefaultImpactsColumns"/>
- <include refid="isNewCodeReferenceIssue"/>
- </sql>
-
- <sql id="issueColumnsInInnerQuery">
- i.kee,
- i.rule_uuid,
- i.severity,
- i.manual_severity,
- i.message,
- i.message_formattings,
- i.line,
- i.locations,
- i.gap,
- i.effort,
- i.status,
- i.resolution,
- i.checksum,
- i.assignee,
- i.author_login,
- i.tags,
- i.rule_description_context_key,
- i.issue_creation_date,
- i.issue_update_date,
- i.issue_close_date,
- i.created_at,
- i.updated_at,
- i.component_uuid,
- i.project_uuid,
- i.issue_type,
- i.quick_fix_available,
- i.code_variants,
- i.clean_code_attribute
- </sql>
-
- <sql id="isNewCodeReferenceIssue" databaseId="mssql">
- cast(case when n.uuid is null then 0 else 1 end as bit) as isNewCodeReferenceIssue
- </sql>
- <sql id="isNewCodeReferenceIssue" databaseId="oracle">
- case when n.uuid is null then 0 else 1 end as isNewCodeReferenceIssue
- </sql>
- <sql id="isNewCodeReferenceIssue">
- n.uuid is not null as isNewCodeReferenceIssue
- </sql>
-
- <sql id="sortColumn">
- <if test="query.sort() != null">,
- <choose>
- <when test="'SEVERITY'.equals(query.sort())">
- i.severity as severity
- </when>
- <when test="'STATUS'.equals(query.sort())">
- i.status as status
- </when>
- <when test="'ASSIGNEE'.equals(query.sort())">
- i.assignee as assigneeUuid
- </when>
- <when test="'CREATION_DATE'.equals(query.sort())">
- i.issue_creation_date as issueCreationTime
- </when>
- <when test="'UPDATE_DATE'.equals(query.sort())">
- i.issue_update_date as issueUpdateTime
- </when>
- <when test="'CLOSE_DATE'.equals(query.sort())">
- i.issue_close_date as issueCloseTime
- </when>
- </choose>
- </if>
- </sql>
-
- <sql id="issueImpactsColumns">
- ii.software_quality as "ii_softwareQuality",
- ii.severity as "ii_severity",
- </sql>
- <sql id="ruleDefaultImpactsColumns">
- rdi.software_quality as "rdi_softwareQuality",
- rdi.severity as "rdi_severity",
- </sql>
-
- <resultMap id="issueResultMap" type="Issue" autoMapping="true">
- <id property="kee" column="kee"/>
-
- <collection property="impacts" column="ii_softwareQuality" notNullColumn="ii_softwareQuality"
- javaType="java.util.Set" ofType="Impact">
- <result property="softwareQuality" column="ii_softwareQuality"/>
- <result property="severity" column="ii_severity"/>
- </collection>
- <collection property="ruleDefaultImpacts" column="rdi_softwareQuality" notNullColumn="rdi_softwareQuality"
- javaType="java.util.Set" ofType="Impact">
- <result property="softwareQuality" column="rdi_softwareQuality"/>
- <result property="severity" column="rdi_severity"/>
- </collection>
- </resultMap>
-
- <insert id="insert" parameterType="Issue" useGeneratedKeys="false">
- INSERT INTO issues (kee, rule_uuid, severity, manual_severity,
- message, message_formattings, line, locations, gap, effort, status, tags, rule_description_context_key,
- resolution, checksum, assignee, author_login, issue_creation_date, issue_update_date,
- issue_close_date, created_at, updated_at, component_uuid, project_uuid, issue_type, quick_fix_available, code_variants,
- clean_code_attribute)
- VALUES (
- #{kee,jdbcType=VARCHAR},
- #{ruleUuid,jdbcType=VARCHAR},
- #{severity,jdbcType=VARCHAR},
- #{manualSeverity,jdbcType=BOOLEAN},
- #{message,jdbcType=VARCHAR},
- #{messageFormattings,jdbcType=BINARY},
- #{line,jdbcType=INTEGER},
- #{locations,jdbcType=BINARY},
- #{gap,jdbcType=DOUBLE}, #{effort,jdbcType=INTEGER}, #{status,jdbcType=VARCHAR},
- #{tagsString,jdbcType=VARCHAR},
- #{ruleDescriptionContextKey,jdbcType=VARCHAR},
- #{resolution,jdbcType=VARCHAR},
- #{checksum,jdbcType=VARCHAR},
- #{assigneeUuid,jdbcType=VARCHAR},
- #{authorLogin,jdbcType=VARCHAR},
- #{issueCreationTime,jdbcType=BIGINT},#{issueUpdateTime,jdbcType=BIGINT}, #{issueCloseTime,jdbcType=BIGINT},
- #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT},
- #{componentUuid,jdbcType=VARCHAR}, #{projectUuid,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER},
- #{quickFixAvailable, jdbcType=BOOLEAN},
- #{codeVariantsString,jdbcType=VARCHAR},
- #{effectiveCleanCodeAttribute,jdbcType=VARCHAR})
- </insert>
-
- <insert id="insertAsNewCodeOnReferenceBranch" parameterType="NewCodeReferenceIssue" useGeneratedKeys="false">
- INSERT INTO new_code_reference_issues (uuid, issue_key, created_at)
- VALUES (
- #{uuid,jdbcType=VARCHAR},
- #{issueKey,jdbcType=VARCHAR},
- #{createdAt,jdbcType=BIGINT})
- </insert>
-
- <insert id="insertIssueImpact" parameterType="map" useGeneratedKeys="false">
- INSERT INTO issues_impacts (issue_key, software_quality, severity)
- VALUES (
- #{issueKey,jdbcType=VARCHAR},
- #{dto.softwareQuality,jdbcType=VARCHAR},
- #{dto.severity,jdbcType=VARCHAR})
- </insert>
-
- <delete id="deleteAsNewCodeOnReferenceBranch" parameterType="String" >
- DELETE FROM new_code_reference_issues
- where issue_key = #{issueKey, jdbcType=VARCHAR}
- </delete>
-
- <delete id="deleteIssueImpacts" parameterType="String" >
- DELETE FROM issues_impacts
- where issue_key = #{issueUuid, jdbcType=VARCHAR}
- </delete>
-
- <!--
- IMPORTANT - invariant columns can't be updated. See IssueDto#toDtoForUpdate()
- -->
- <update id="update" parameterType="Issue">
- update issues set
- severity=#{severity,jdbcType=VARCHAR},
- manual_severity=#{manualSeverity,jdbcType=BOOLEAN},
- message=#{message,jdbcType=VARCHAR},
- message_formattings=#{messageFormattings,jdbcType=BINARY},
- line=#{line,jdbcType=INTEGER},
- locations=#{locations,jdbcType=BINARY},
- gap=#{gap,jdbcType=DOUBLE},
- effort=#{effort,jdbcType=INTEGER},
- status=#{status,jdbcType=VARCHAR},
- resolution=#{resolution,jdbcType=VARCHAR},
- checksum=#{checksum,jdbcType=VARCHAR},
- assignee=#{assigneeUuid,jdbcType=VARCHAR},
- author_login=#{authorLogin,jdbcType=VARCHAR},
- tags=#{tagsString,jdbcType=VARCHAR},
- rule_description_context_key=#{ruleDescriptionContextKey,jdbcType=VARCHAR},
- project_uuid=#{projectUuid,jdbcType=VARCHAR},
- issue_creation_date=#{issueCreationTime,jdbcType=BIGINT},
- issue_update_date=#{issueUpdateTime,jdbcType=BIGINT},
- issue_close_date=#{issueCloseTime,jdbcType=BIGINT},
- updated_at=#{updatedAt,jdbcType=BIGINT},
- issue_type=#{type,jdbcType=INTEGER},
- code_variants=#{codeVariantsString,jdbcType=VARCHAR},
- clean_code_attribute=#{effectiveCleanCodeAttribute,jdbcType=VARCHAR}
- where kee = #{kee}
- </update>
-
- <!--
- IMPORTANT - invariant columns can't be updated. See IssueDto#toDtoForUpdate()
- -->
- <update id="updateIfBeforeSelectedDate" parameterType="Issue">
- update issues set
- severity=#{severity,jdbcType=VARCHAR},
- manual_severity=#{manualSeverity,jdbcType=BOOLEAN},
- message=#{message,jdbcType=VARCHAR},
- message_formattings=#{messageFormattings,jdbcType=BINARY},
- line=#{line,jdbcType=INTEGER},
- locations=#{locations,jdbcType=BINARY},
- gap=#{gap,jdbcType=DOUBLE},
- effort=#{effort,jdbcType=INTEGER},
- status=#{status,jdbcType=VARCHAR},
- resolution=#{resolution,jdbcType=VARCHAR},
- checksum=#{checksum,jdbcType=VARCHAR},
- assignee=#{assigneeUuid,jdbcType=VARCHAR},
- author_login=#{authorLogin,jdbcType=VARCHAR},
- tags=#{tagsString,jdbcType=VARCHAR},
- rule_description_context_key=#{ruleDescriptionContextKey,jdbcType=VARCHAR},
- component_uuid=#{componentUuid,jdbcType=VARCHAR},
- project_uuid=#{projectUuid,jdbcType=VARCHAR},
- issue_creation_date=#{issueCreationTime,jdbcType=BIGINT},
- issue_update_date=#{issueUpdateTime,jdbcType=BIGINT},
- issue_close_date=#{issueCloseTime,jdbcType=BIGINT},
- updated_at=#{updatedAt,jdbcType=BIGINT},
- issue_type=#{type,jdbcType=INTEGER},
- code_variants=#{codeVariantsString,jdbcType=VARCHAR},
- clean_code_attribute=#{effectiveCleanCodeAttribute,jdbcType=VARCHAR}
- where kee = #{kee} and updated_at <= #{selectedAt}
- </update>
-
- <select id="selectByKey" parameterType="String" resultMap="issueResultMap">
- select
- <include refid="issueColumns"/>,
- u.login as assigneeLogin
- from issues i
- inner join rules r on r.uuid=i.rule_uuid
- inner join components p on p.uuid=i.component_uuid
- inner join components root on root.uuid=i.project_uuid
- left join users u on i.assignee = u.uuid
- left join new_code_reference_issues n on i.kee = n.issue_key
- left outer join issues_impacts ii on i.kee = ii.issue_key
- left outer join rules_default_impacts rdi on r.uuid = rdi.rule_uuid
- where i.kee=#{kee,jdbcType=VARCHAR}
- </select>
-
- <select id="scrollNonClosedByComponentUuid" parameterType="String" resultMap="issueResultMap" fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY" resultOrdered="true">
- select
- <include refid="issueColumns"/>
- from issues i
- inner join rules r on r.uuid=i.rule_uuid
- inner join components p on p.uuid=i.component_uuid
- inner join components root on root.uuid=i.project_uuid
- left join new_code_reference_issues n on i.kee = n.issue_key
- left outer join issues_impacts ii on i.kee = ii.issue_key
- left outer join rules_default_impacts rdi on r.uuid = rdi.rule_uuid
- where
- i.component_uuid = #{componentUuid,jdbcType=VARCHAR} and
- i.status <> 'CLOSED'
- order by
- i.kee
- </select>
-
- <select id="scrollClosedByComponentUuid" resultMap="issueResultMap" fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY" resultOrdered="true">
- select
- <include refid="issueColumns"/>,
- ic.change_data as closedChangeData
- from issues i
- inner join rules r on
- r.uuid = i.rule_uuid
- inner join components p on
- p.uuid = i.component_uuid
- inner join components root on
- root.uuid = i.project_uuid
- inner join issue_changes ic on
- ic.issue_key = i.kee
- and ic.change_type = 'diff'
- and ic.change_data like '%status=%|CLOSED%'
- left join new_code_reference_issues n on
- i.kee = n.issue_key
- left outer join issues_impacts ii on
- i.kee = ii.issue_key
- left outer join rules_default_impacts rdi on
- r.uuid = rdi.rule_uuid
- where
- i.component_uuid = #{componentUuid,jdbcType=VARCHAR}
- and i.status = 'CLOSED'
- and i.issue_close_date is not null
- and i.issue_close_date >= #{closeDateAfter,jdbcType=BIGINT}
- order by
- i.kee, ic.issue_change_creation_date desc
- </select>
-
- <resultMap id="indexedIssueResultMap" type="org.sonar.db.issue.IndexedIssueDto" autoMapping="true">
- <id property="issueKey" column="issueKey"/>
-
- <collection property="impacts" column="ii_softwareQuality" notNullColumn="ii_softwareQuality"
- javaType="java.util.Set" ofType="Impact">
- <result property="softwareQuality" column="ii_softwareQuality"/>
- <result property="severity" column="ii_severity"/>
- </collection>
- <collection property="ruleDefaultImpacts" column="rdi_softwareQuality" notNullColumn="rdi_softwareQuality"
- javaType="java.util.Set" ofType="Impact">
- <result property="softwareQuality" column="rdi_softwareQuality"/>
- <result property="severity" column="rdi_severity"/>
- </collection>
- </resultMap>
-
- <select id="scrollIssuesForIndexation" parameterType="map" resultMap="indexedIssueResultMap" fetchSize="${_scrollFetchSize}"
- resultSetType="FORWARD_ONLY" resultOrdered="true">
- select
- i.kee as issueKey,
- i.assignee,
- i.line,
- i.resolution,
- i.severity,
- i.status,
- i.effort,
- i.author_login as authorLogin,
- i.issue_close_date as issueCloseDate,
- i.issue_creation_date as issueCreationDate,
- i.issue_update_date as issueUpdateDate,
- r.uuid as ruleUuid,
- r.language as language,
- i.clean_code_attribute as cleanCodeAttribute,
- r.clean_code_attribute as ruleCleanCodeAttribute,
- c.uuid as componentUuid,
- c.path,
- c.scope,
- c.branch_uuid as branchUuid,
- pb.is_main as isMain,
- pb.project_uuid as projectUuid,
- i.tags,
- i.issue_type as issueType,
- r.security_standards as securityStandards,
- c.qualifier,
- i.code_variants as codeVariants,
- <include refid="issueImpactsColumns"/>
- <include refid="ruleDefaultImpactsColumns"/>
- <include refid="isNewCodeReferenceIssue"/>
- from issues i
- inner join rules r on r.uuid = i.rule_uuid
- inner join components c on c.uuid = i.component_uuid
- inner join project_branches pb on c.branch_uuid = pb.uuid
- left join new_code_reference_issues n on n.issue_key = i.kee
- left outer join issues_impacts ii on i.kee = ii.issue_key
- left outer join rules_default_impacts rdi on r.uuid = rdi.rule_uuid
- <where>
- <if test="branchUuid != null">
- and c.branch_uuid = #{branchUuid,jdbcType=VARCHAR} and i.project_uuid = #{branchUuid,jdbcType=VARCHAR}
- </if>
- <if test="issueKeys != null">
- and i.kee in
- <foreach collection="issueKeys" open="(" close=")" item="key" separator=",">
- #{key,jdbcType=VARCHAR}
- </foreach>
- </if>
- </where>
- order by i.kee
- </select>
-
- <select id="selectComponentUuidsOfOpenIssuesForProjectUuid" parameterType="string" resultType="string">
- select distinct(i.component_uuid)
- from issues i
- where i.project_uuid=#{projectUuid,jdbcType=VARCHAR} and i.status <> 'CLOSED'
- </select>
-
- <select id="selectByKeys" parameterType="map" resultMap="issueResultMap">
- select
- <include refid="issueColumns"/>,
- u.login as assigneeLogin
- from issues i
- inner join rules r on r.uuid=i.rule_uuid
- inner join components p on p.uuid=i.component_uuid
- inner join components root on root.uuid=i.project_uuid
- left join users u on i.assignee = u.uuid
- left join new_code_reference_issues n on i.kee = n.issue_key
- left outer join issues_impacts ii on i.kee = ii.issue_key
- left outer join rules_default_impacts rdi on r.uuid = rdi.rule_uuid
- where i.kee in
- <foreach collection="list" open="(" close=")" item="key" separator=",">
- #{key,jdbcType=VARCHAR}
- </foreach>
- </select>
-
- <select id="selectByKeysIfNotUpdatedAt" parameterType="map" resultMap="issueResultMap">
- select
- <include refid="issueColumns"/>
- from issues i
- inner join rules r on r.uuid=i.rule_uuid
- inner join components p on p.uuid=i.component_uuid
- inner join components root on root.uuid=i.project_uuid
- left join new_code_reference_issues n on i.kee = n.issue_key
- left outer join issues_impacts ii on i.kee = ii.issue_key
- left outer join rules_default_impacts rdi on r.uuid = rdi.rule_uuid
- where
- i.kee in
- <foreach collection="keys" open="(" close=")" item="key" separator=",">
- #{key,jdbcType=VARCHAR}
- </foreach>
- and i.updated_at <> #{updatedAt,jdbcType=BIGINT}
- </select>
-
- <select id="selectOpenByComponentUuids" parameterType="map" resultType="PrIssue">
- select
- i.kee as kee,
- i.message as message,
- i.line as line,
- i.status as status,
- i.checksum as checksum,
- i.issue_update_date as issueUpdateDate,
- r.plugin_rule_key as ruleKey,
- r.plugin_name as ruleRepo,
- b.kee as branchKey,
- b.branch_type as branchType
- from issues i
- inner join rules r on r.uuid = i.rule_uuid
- inner join project_branches b on i.project_uuid = b.uuid
- where i.component_uuid in
- <foreach collection="list" open="(" close=")" item="key" separator=",">
- #{key,jdbcType=VARCHAR}
- </foreach>
- and i.status <> 'CLOSED'
- </select>
-
- <select id="selectIssueGroupsByComponent" resultType="org.sonar.db.issue.IssueGroupDto" parameterType="map">
- select
- i.issue_type as ruleType,
- i.severity as severity,
- i.resolution as resolution,
- i.status as status, sum(i.effort) as effort,
- count(i.issue_type) as "count",
- <if test="leakPeriodBeginningDate >= 0">
- (i.issue_creation_date > #{leakPeriodBeginningDate,jdbcType=BIGINT}) as inLeak
- </if>
- <if test="leakPeriodBeginningDate < 0">
- CASE WHEN n.uuid is null THEN false ELSE true END as inLeak
- </if>
- from issues i
- <if test="leakPeriodBeginningDate < 0">
- left join new_code_reference_issues n on n.issue_key = i.kee
- </if>
- where i.status <> 'CLOSED'
- and i.component_uuid = #{component.uuid,jdbcType=VARCHAR}
- group by i.issue_type, i.severity, i.resolution, i.status, inLeak
- </select>
-
- <select id="selectIssueGroupsByComponent" resultType="org.sonar.db.issue.IssueGroupDto" parameterType="map" databaseId="oracle">
- <include refid="selectIssueGroupsByComponentVendorSpecific"/>
- </select>
-
- <select id="selectIssueGroupsByComponent" resultType="org.sonar.db.issue.IssueGroupDto" parameterType="map" databaseId="mssql">
- <include refid="selectIssueGroupsByComponentVendorSpecific"/>
- </select>
-
- <sql id="selectIssueGroupsByComponentVendorSpecific">
- select
- i2.issue_type as ruleType,
- i2.severity as severity,
- i2.resolution as resolution,
- i2.status as status,
- sum(i2.effort) as effort,
- count(i2.issue_type) as "count",
- i2.inLeak as inLeak
- from (
- select
- i.issue_type,
- i.severity,
- i.resolution,
- i.status,
- i.effort,
- <if test="leakPeriodBeginningDate >= 0">
- case when i.issue_creation_date > #{leakPeriodBeginningDate,jdbcType=BIGINT} then 1 else 0 end as inLeak
- </if>
- <if test="leakPeriodBeginningDate < 0">
- case when n.uuid is null then 0 else 1 end as inLeak
- </if>
- from issues i
- <if test="leakPeriodBeginningDate < 0">
- left join new_code_reference_issues n on n.issue_key = i.kee
- </if>
- where i.status <> 'CLOSED'
- and i.component_uuid = #{component.uuid,jdbcType=VARCHAR}
- ) i2
- group by i2.issue_type, i2.severity, i2.resolution, i2.status, i2.inLeak
- </sql>
-
- <select id="selectIssueImpactGroupsByComponent" resultType="org.sonar.db.issue.IssueImpactGroupDto" parameterType="map">
- select
- i2.status as status,
- i2.resolution as resolution,
- i2.software_quality as softwareQuality,
- i2.severity as severity,
- count(i2.kee) as "count",
- i2.inLeak as inLeak
- from (
- select
- i.status,
- i.resolution,
- i.kee,
- ii.software_quality,
- ii.severity,
- <if test="leakPeriodBeginningDate >= 0">
- case when i.issue_creation_date > #{leakPeriodBeginningDate,jdbcType=BIGINT} then ${_true} else ${_false} end as inLeak
- </if>
- <if test="leakPeriodBeginningDate < 0">
- case when n.uuid is null then ${_false} else ${_true} end as inLeak
- </if>
- from issues i
- inner join issues_impacts ii on i.kee = ii.issue_key
- <if test="leakPeriodBeginningDate < 0">
- left join new_code_reference_issues n on n.issue_key = i.kee
- </if>
- where i.status <> 'CLOSED'
- and (i.resolution is null or i.resolution = 'WONTFIX')
- and i.component_uuid = #{component.uuid,jdbcType=VARCHAR}
- ) i2
- group by i2.status, i2.resolution, i2.software_quality, i2.severity, i2.inLeak
- </select>
-
- <select id="selectIssueKeysByComponentUuid" parameterType="string" resultType="string">
- select
- i.kee
- from issues i
- where
- i.project_uuid=#{componentUuid,jdbcType=VARCHAR}
- </select>
-
- <select id="selectIssueKeysByComponentUuidWithFilters" parameterType="string" resultType="string">
- select
- i.kee
- from rules r
- inner join issues i on i.rule_uuid = r.uuid
- where
- i.project_uuid=#{componentUuid,jdbcType=VARCHAR}
- AND i.status <> 'CLOSED'
- <if test="includingRepositories.size() > 0">
- AND r.plugin_name IN
- <foreach item="ruleRepository" index="index" collection="includingRepositories" open="(" separator="," close=")">
- #{ruleRepository}
- </foreach>
- </if>
- <if test="excludingRepositories.size() > 0">
- AND r.plugin_name NOT IN
- <foreach item="ruleRepository" index="index" collection="excludingRepositories" open="(" separator="," close=")">
- #{ruleRepository}
- </foreach>
- </if>
- <if test="languages.size() > 0">
- AND r.language IN
- <foreach item="language" index="index" collection="languages" open="(" separator="," close=")">
- #{language}
- </foreach>
- </if>
- order by i.kee
- <include refid="org.sonar.db.common.Common.pagination"/>
- </select>
-
- <select id="selectIssueKeysByComponentUuidAndChangedSinceDate" parameterType="map" resultType="string">
- select
- i.kee
- from rules r
- inner join issues i on i.rule_uuid = r.uuid
- where
- i.project_uuid=#{componentUuid,jdbcType=VARCHAR}
- AND i.issue_update_date >= #{changedSince,jdbcType=BIGINT}
- AND i.status <> 'CLOSED'
- <if test="includingRepositories.size() > 0">
- AND r.plugin_name IN
- <foreach item="ruleRepository" index="index" collection="includingRepositories" open="(" separator="," close=")">
- #{ruleRepository}
- </foreach>
- </if>
- <if test="excludingRepositories.size() > 0">
- AND r.plugin_name NOT IN
- <foreach item="ruleRepository" index="index" collection="excludingRepositories" open="(" separator="," close=")">
- #{ruleRepository}
- </foreach>
- </if>
- <if test="languages.size() > 0">
- AND r.language IN
- <foreach item="language" index="index" collection="languages" open="(" separator="," close=")">
- #{language}
- </foreach>
- </if>
- order by i.kee
- <include refid="org.sonar.db.common.Common.pagination"/>
- </select>
-
- <sql id="selectByBranchColumns">
- i.kee as kee,
- i.rule_uuid as ruleUuid,
- i.created_at as createdAt,
- i.issue_creation_date as issueCreationTime,
- i.status as status,
- i.resolution as resolution,
- r.rule_type as ruleType,
- r.plugin_name as ruleRepo,
- r.plugin_rule_key as ruleKey,
- i.message as message,
- i.message_formattings as messageFormattings,
- i.severity as severity,
- i.manual_severity as manualSeverity,
- i.issue_type as type,
- i.locations as locations,
- i.component_uuid as component_uuid,
- i.assignee as assigneeUuid,
- u.login as assigneeLogin,
- i.rule_description_context_key as ruleDescriptionContextKey,
- <include refid="issueImpactsColumns"/>
- <include refid="ruleDefaultImpactsColumns"/>
- i.clean_code_attribute as cleanCodeAttribute,
- r.clean_code_attribute as ruleCleanCodeAttribute
- </sql>
-
- <select id="selectByBranch" parameterType="map" resultMap="issueResultMap" resultOrdered="true">
- select
- <include refid="selectByBranchColumns"/>
- , p.path as filePath
- from issues i
- inner join rules r on r.uuid = i.rule_uuid
- inner join components p on p.uuid=i.component_uuid
- left join users u on i.assignee = u.uuid
- left outer join issues_impacts ii on i.kee = ii.issue_key
- left outer join rules_default_impacts rdi on r.uuid = rdi.rule_uuid
- where
- <if test="keys.size() > 0">
- i.kee IN
- <foreach collection="keys" open="(" close=")" item="key" separator=",">
- #{key,jdbcType=VARCHAR}
- </foreach>
- </if>
- <if test="changedSince != null">
- AND i.issue_update_date >= #{changedSince,jdbcType=BIGINT}
- </if>
- order by i.kee
- </select>
-
- <select id="selectRecentlyClosedIssues" resultType="string">
- select i.kee
- from rules r
- inner join issues i on r.uuid = i.rule_uuid
- where
- i.project_uuid = #{queryParams.branchUuid}
- AND issue_update_date >= #{queryParams.changedSince}
- AND i.status = 'CLOSED'
- <if test="queryParams.ruleRepositories.size() > 0">
- AND r.plugin_name IN
- <foreach item="ruleRepository" index="index" collection="queryParams.ruleRepositories" open="(" separator="," close=")">
- #{ruleRepository}
- </foreach>
- </if>
- <if test="queryParams.excludingRuleRepositories.size() > 0">
- AND r.plugin_name NOT IN
- <foreach item="ruleRepository" index="index" collection="queryParams.excludingRuleRepositories" open="(" separator="," close=")">
- #{ruleRepository}
- </foreach>
- </if>
- <if test="queryParams.languages.size() > 0">
- AND r.language IN
- <foreach item="language" index="index" collection="queryParams.languages" open="(" separator="," close=")">
- #{language}
- </foreach>
- </if>
- </select>
-
- <select id="selectIssueKeysByQuery" parameterType="map" resultType="string">
- select
- i.kee
- from issues i
- inner join components p on p.uuid=i.component_uuid
- inner join components root on root.uuid=i.project_uuid
- inner join project_branches pb on pb.uuid=i.project_uuid
- left join new_code_reference_issues n on i.kee = n.issue_key
- <if test="query.softwareQualities.size() > 0">
- left join issues_impacts im on i.kee = im.issue_key
- </if>
- <where>
- <if test="query.project != null">
- root.kee = #{query.project,jdbcType=VARCHAR}
- </if>
- <if test="query.component != null">
- AND p.kee = #{query.component,jdbcType=VARCHAR}
- </if>
- <if test="query.branch != null">
- AND pb.kee = #{query.branch,jdbcType=VARCHAR}
- </if>
- <if test="query.pullRequest != null">
- AND pb.kee = #{query.pullRequest,jdbcType=VARCHAR}
- </if>
- <if test="query.types.size() > 0">
- AND i.issue_type IN
- <foreach collection="query.types" open="(" close=")" item="type" separator=",">
- #{type,jdbcType=VARCHAR}
- </foreach>
- </if>
- <if test="query.softwareQualities.size() > 0">
- AND im.software_quality IN
- <foreach collection="query.softwareQualities" open="(" close=")" item="type" separator=",">
- #{type,jdbcType=VARCHAR}
- </foreach>
- </if>
- <if test="query.statuses.size() > 0">
- AND i.status IN
- <foreach collection="query.statuses" open="(" close=")" item="status" separator=",">
- #{status,jdbcType=VARCHAR}
- </foreach>
- </if>
- <if test="query.resolved != null">
- AND i.resolution is <if test="query.resolved">not</if> null
- </if>
- <if test="query.resolutions.size() > 0">
- AND i.resolution IN
- <foreach collection="query.resolutions" open="(" close=")" item="resolution" separator=",">
- #{resolution,jdbcType=VARCHAR}
- </foreach>
- </if>
- <if test="query.newCodeOnReference == true">
- AND n.uuid IS NOT NULL
- </if>
- <if test="query.createdAfter != null">
- AND i.issue_creation_date >= #{query.createdAfter,jdbcType=BIGINT}
- </if>
- </where>
- <if test="_databaseId == 'mssql'">
- <!-- order by clause is required if using offset rows fetch next on MSSQL Database -->
- order by (select null)
- </if>
- <include refid="org.sonar.db.common.Common.pagination"/>
- </select>
- </mapper>
|