Skip to content

Commit

Permalink
v1.30.5-8: Little patch for pipeline ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
igcherkaev committed Oct 24, 2024
1 parent e3e8c27 commit 2ce42ef
Showing 1 changed file with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,39 @@ public List<Pipeline> listByApplication(
if (p1.getIndex() == null && p2.getIndex() != null) {
return 1;
}
if (p1.getIndex() != null
&& p2.getIndex() != null
&& !p1.getIndex().equals(p2.getIndex())) {
return p1.getIndex() - p2.getIndex();
if (p1.getIndex() != null && !p1.getIndex().equals(p2.getIndex())) {
int weight = p1.getIndex() > p2.getIndex() ? -1 : 1;
log.debug(
"Sorting pipelines: normal sort (weight: "
+ weight
+ ") for '"
+ p1.getName()
+ "'/"
+ p1.getIndex()
+ " and '"
+ p2.getName()
+ "'/"
+ p2.getIndex());
return weight;
}
return Optional.ofNullable(p1.getName())
.orElse(p1.getId())
.compareToIgnoreCase(Optional.ofNullable(p2.getName()).orElse(p2.getId()));
if (p1.getIndex() != null) {
log.debug("Sorting pipelines: p1 and p2 have same index of " + p1.getIndex());
}
int weight =
Optional.ofNullable(p1.getName())
.orElse(p1.getId())
.compareToIgnoreCase(Optional.ofNullable(p2.getName()).orElse(p2.getId()));
log.debug(
"Sorting pipelines with equal index " + p1.getIndex() + ": returning " + weight);
return weight;
});

int i = 0;
for (Pipeline p : pipelines) {
p.setIndex(i);
if (p.getIndex() == null) {
p.setIndex(i);
log.debug("Sorting pipelines: assigned index " + i + " to pipeline " + p);
}
i++;
}

Expand Down

0 comments on commit 2ce42ef

Please sign in to comment.