feat: Queueの割当に優先順位が適用されるように

This commit is contained in:
usbharu 2024-03-18 14:52:02 +09:00
parent cbfcc21dee
commit 4dbffdb2d9
1 changed files with 2 additions and 1 deletions

View File

@ -20,6 +20,7 @@ import com.mongodb.client.model.Filters.*
import com.mongodb.client.model.FindOneAndUpdateOptions import com.mongodb.client.model.FindOneAndUpdateOptions
import com.mongodb.client.model.ReplaceOptions import com.mongodb.client.model.ReplaceOptions
import com.mongodb.client.model.ReturnDocument import com.mongodb.client.model.ReturnDocument
import com.mongodb.client.model.Sorts
import com.mongodb.client.model.Updates.set import com.mongodb.client.model.Updates.set
import com.mongodb.kotlin.client.coroutine.MongoDatabase import com.mongodb.kotlin.client.coroutine.MongoDatabase
import dev.usbharu.owl.broker.domain.model.queuedtask.QueuedTask import dev.usbharu.owl.broker.domain.model.queuedtask.QueuedTask
@ -88,7 +89,7 @@ class MongodbQueuedTaskRepository(
`in`("task.name", tasks), `in`("task.name", tasks),
eq(QueuedTaskMongodb::isActive.name, true) eq(QueuedTaskMongodb::isActive.name, true)
) )
).map { it.toQueuedTask(propertySerializerFactory) }.flowOn(Dispatchers.IO) ).sort(Sorts.descending("priority")).map { it.toQueuedTask(propertySerializerFactory) }.flowOn(Dispatchers.IO)
} }
override fun findByQueuedAtBeforeAndIsActiveIsTrue(instant: Instant): Flow<QueuedTask> { override fun findByQueuedAtBeforeAndIsActiveIsTrue(instant: Instant): Flow<QueuedTask> {