mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-27 09:50:39 +00:00
@@ -105,25 +105,9 @@ public class FastJobStorage implements JobStorage {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
} else {
|
} else {
|
||||||
return Stream.of(jobs)
|
return Stream.of(jobs)
|
||||||
.groupBy(jobSpec -> {
|
|
||||||
String queueKey = jobSpec.getQueueKey();
|
|
||||||
if (queueKey != null) {
|
|
||||||
return queueKey;
|
|
||||||
} else {
|
|
||||||
return jobSpec.getId();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.map(byQueueKey ->
|
|
||||||
Stream.of(byQueueKey.getValue()).sorted((j1, j2) -> Long.compare(j1.getCreateTime(), j2.getCreateTime()))
|
|
||||||
.findFirst()
|
|
||||||
.orElse(null)
|
|
||||||
)
|
|
||||||
.withoutNulls()
|
|
||||||
.filter(j -> {
|
|
||||||
List<DependencySpec> dependencies = dependenciesByJobId.get(j.getId());
|
|
||||||
return dependencies == null || dependencies.isEmpty();
|
|
||||||
})
|
|
||||||
.filterNot(JobSpec::isRunning)
|
.filterNot(JobSpec::isRunning)
|
||||||
|
.filter(this::firstInQueue)
|
||||||
|
.filter(j -> !dependenciesByJobId.containsKey(j.getId()) || dependenciesByJobId.get(j.getId()).isEmpty())
|
||||||
.filter(j -> j.getNextRunAttemptTime() <= currentTime)
|
.filter(j -> j.getNextRunAttemptTime() <= currentTime)
|
||||||
.sorted((j1, j2) -> Long.compare(j1.getCreateTime(), j2.getCreateTime()))
|
.sorted((j1, j2) -> Long.compare(j1.getCreateTime(), j2.getCreateTime()))
|
||||||
.toList();
|
.toList();
|
||||||
|
Reference in New Issue
Block a user