Skip to content

Commit

Permalink
#940: Use correct component IDs when extracting analysis date
Browse files Browse the repository at this point in the history
The component ID was being used to create a map of analysis dates to
items, but the Pull Request's component ID did not map into this item,
so the Pull Request web service was always returning the analysis date
as empty. The service has been altered to use the root component ID as
was used in the search to ensure the IDs align.
  • Loading branch information
mc1arke committed Aug 11, 2024
1 parent 137e8e6 commit e997fa0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void handleProjectRequest(ProjectDto project, Request request, Response r
.selectByComponentUuidsAndMetricKeys(dbSession, pullRequestUuids, List.of(CoreMetrics.ALERT_STATUS_KEY)).stream()
.collect(Collectors.toMap(LiveMeasureDto::getComponentUuid, Function.identity()));
Map<String, String> analysisDateByBranchUuid = getDbClient().snapshotDao().selectLastAnalysesByRootComponentUuids(dbSession, pullRequestUuids).stream()
.collect(Collectors.toMap(SnapshotDto::getUuid, s -> DateUtils.formatDateTime(s.getCreatedAt())));
.collect(Collectors.toMap(SnapshotDto::getRootComponentUuid, s -> DateUtils.formatDateTime(s.getCreatedAt())));

ProjectPullRequests.ListWsResponse.Builder protobufResponse = ProjectPullRequests.ListWsResponse.newBuilder();
pullRequests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void shouldExecuteRequestWithValidParameter() {

SnapshotDao snapshotDao = mock(SnapshotDao.class);
when(dbClient.snapshotDao()).thenReturn(snapshotDao);
when(snapshotDao.selectLastAnalysesByRootComponentUuids(any(), any())).thenReturn(List.of(new SnapshotDto().setUuid("componentUuid").setCreatedAt(1234L)));
when(snapshotDao.selectLastAnalysesByRootComponentUuids(any(), any())).thenReturn(List.of(new SnapshotDto().setRootComponentUuid("uuid3").setCreatedAt(1234567891234L)));

Response response = mock(Response.class);

Expand All @@ -157,6 +157,7 @@ void shouldExecuteRequestWithValidParameter() {
.setKey("prKey2")
.setTitle("title2")
.setBranch("prBranch2")
.setAnalysisDate("2009-02-13T23:31:31+0000")
.setStatus(ProjectPullRequests.Status.newBuilder()
.build())
.setIsOrphan(true)
Expand Down

0 comments on commit e997fa0

Please sign in to comment.