in ddm-rrm-gerrit-integration/src/main/java/com/epam/digital/data/platform/management/gerritintegration/service/GerritServiceImpl.java [96:120]
public ChangeInfoDto getLastMergedMR() {
var query = String.format("project:%s+status:merged+owner:%s",
gerritPropertiesConfig.getRepository(), gerritPropertiesConfig.getUser());
var changes = gerritApi.changes();
try {
var changeInfoList = changes.query(query).withLimit(10).get();
if (changeInfoList.isEmpty()) {
return null;
}
var changeId = changeInfoList.stream()
.max(Comparator.comparing(changeInfo -> changeInfo.submitted))
.get().changeId;
return gerritMapper.toChangeInfoDto(changes.id(changeId).get());
} catch (HttpStatusException ex) {
if (ex.getStatusCode() == HttpStatus.NOT_FOUND.value()) {
throw new GerritChangeNotFoundException("Could not found last merged change", ex);
} else {
throw new GerritCommunicationException(
"Something went wrong wile getting last merged change", ex);
}
} catch (RestApiException ex) {
throw new GerritCommunicationException("Something went wrong wile getting last merged change",
ex);
}
}