revert to also respecting order of models in a group
This commit is contained in:
parent
c91b410307
commit
cac8ee37d9
|
@ -20,6 +20,8 @@ import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class RecordingPreconditions {
|
public class RecordingPreconditions {
|
||||||
|
|
||||||
|
@ -199,13 +201,16 @@ public class RecordingPreconditions {
|
||||||
|
|
||||||
// go through each model in group in descendind priority order, checking this model last amongst same-prio models
|
// go through each model in group in descendind priority order, checking this model last amongst same-prio models
|
||||||
// this is to make sure that we only stop lower priority recordings in favor of this one. I.e. if same-prio model is recordnig, let it run
|
// this is to make sure that we only stop lower priority recordings in favor of this one. I.e. if same-prio model is recordnig, let it run
|
||||||
for (var groupModel : modelGroup.get().getModelUrls().stream()
|
var models = modelGroup.get().getModelUrls().stream()
|
||||||
.map(modelUrl -> getModelForUrl(modelUrl))
|
.map(modelUrl -> getModelForUrl(modelUrl))
|
||||||
.filter(x -> x.isPresent())
|
.filter(x -> x.isPresent())
|
||||||
.map(x -> x.get())
|
.map(x -> x.get())
|
||||||
|
.toList();
|
||||||
|
for (var groupModel : IntStream.range(0, models.size()).boxed()
|
||||||
.sorted(Comparator
|
.sorted(Comparator
|
||||||
.comparing((Model m) -> m.getPriority()).reversed() // high to low
|
.comparing((Integer i) -> models.get(i).getPriority()).reversed() // high to low
|
||||||
.thenComparing((Model m) -> m.getUrl().equals(model.getUrl()))) // this model last (false -> true)
|
.thenComparing((Integer i) -> i)) // in group's order
|
||||||
|
.map((Integer i) -> models.get(i))
|
||||||
.toList()) {
|
.toList()) {
|
||||||
if (model.getUrl().equals(groupModel.getUrl())) {
|
if (model.getUrl().equals(groupModel.getUrl())) {
|
||||||
// no other model with higher prio is online, start recording
|
// no other model with higher prio is online, start recording
|
||||||
|
|
Loading…
Reference in New Issue