@@ -58,6 +58,10 @@ public class IssueDao implements Dao { | |||
return executeLargeInputs(keys, mapper(session)::selectByKeys); | |||
} | |||
public Set<String> selectIssueKeysByComponentUuid(DbSession session, String componentUuid) { | |||
return mapper(session).selectIssueKeysByComponentUuid(componentUuid); | |||
} | |||
public List<IssueDto> selectByComponentUuidPaginated(DbSession session, String componentUuid, int page) { | |||
return mapper(session).selectByComponentUuidPaginated(componentUuid, Pagination.forPage(page).andSize(DEFAULT_PAGE_SIZE)); | |||
} |
@@ -37,6 +37,8 @@ public interface IssueMapper { | |||
List<IssueDto> selectByKeys(List<String> keys); | |||
Set<String> selectIssueKeysByComponentUuid(@Param("componentUuid") String componentUuid); | |||
List<IssueDto> selectByComponentUuidPaginated(@Param("componentUuid") String componentUuid, | |||
@Param("pagination") Pagination pagination); | |||
@@ -353,6 +353,14 @@ | |||
group by i2.issue_type, i2.severity, i2.resolution, i2.status, 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="selectByComponentUuidPaginated" parameterType="map" resultType="Issue"> | |||
select | |||
<include refid="issueColumns"/> | |||
@@ -361,7 +369,7 @@ | |||
inner join components p on p.uuid=i.component_uuid | |||
inner join components root on root.uuid=i.project_uuid | |||
where i.project_uuid=#{componentUuid,jdbcType=VARCHAR} | |||
order by i.kee | |||
order by i.issue_creation_date ASC | |||
limit #{pagination.pageSize,jdbcType=INTEGER} offset #{pagination.offset,jdbcType=INTEGER} | |||
</select> | |||
@@ -370,7 +378,7 @@ | |||
<include refid="issueColumns"/> | |||
from | |||
(select | |||
row_number() over(order by i.kee) as row_number, | |||
row_number() over(order by i.issue_creation_date ASC) as row_number, | |||
<include refid="issueColumnsInInnerQuery" /> | |||
from issues i | |||
where i.project_uuid=#{componentUuid,jdbcType=VARCHAR} | |||
@@ -392,7 +400,7 @@ | |||
<include refid="issueColumnsInInnerQuery"/> | |||
from issues i | |||
where i.project_uuid=#{componentUuid,jdbcType=VARCHAR} | |||
order by i.kee | |||
order by i.issue_creation_date ASC | |||
) t | |||
) i | |||
where |
@@ -23,6 +23,7 @@ import java.util.Arrays; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import java.util.Set; | |||
import java.util.stream.Stream; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
@@ -128,6 +129,17 @@ public class IssueDaoTest { | |||
assertThat(issues).extracting("key").containsOnly("I1", "I2"); | |||
} | |||
@Test | |||
public void selectIssueKeysByComponentUuid() { | |||
// contains I1 and I2 | |||
prepareTables(); | |||
Set<String> issues = underTest.selectIssueKeysByComponentUuid(db.getSession(), PROJECT_UUID); | |||
// results are not ordered, so do not use "containsExactly" | |||
assertThat(issues).containsOnly("I1", "I2"); | |||
} | |||
@Test | |||
public void selectByComponentUuidPaginated() { | |||
// contains I1 and I2 |