mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Change job priority on queue page
This commit is contained in:
@ -5,8 +5,10 @@ import cats.effect._
|
||||
import cats.implicits._
|
||||
|
||||
import docspell.backend.ops.OJob.{CollectiveQueueState, JobCancelResult}
|
||||
import docspell.common.Priority
|
||||
import docspell.common.{Ident, JobState}
|
||||
import docspell.store.Store
|
||||
import docspell.store.UpdateResult
|
||||
import docspell.store.queries.QJob
|
||||
import docspell.store.records.{RJob, RJobLog}
|
||||
|
||||
@ -15,6 +17,8 @@ trait OJob[F[_]] {
|
||||
def queueState(collective: Ident, maxResults: Int): F[CollectiveQueueState]
|
||||
|
||||
def cancelJob(id: Ident, collective: Ident): F[JobCancelResult]
|
||||
|
||||
def setPriority(id: Ident, collective: Ident, prio: Priority): F[UpdateResult]
|
||||
}
|
||||
|
||||
object OJob {
|
||||
@ -56,6 +60,9 @@ object OJob {
|
||||
.toVector
|
||||
.map(CollectiveQueueState)
|
||||
|
||||
def setPriority(id: Ident, collective: Ident, prio: Priority): F[UpdateResult] =
|
||||
UpdateResult.fromUpdate(store.transact(RJob.setPriority(id, collective, prio)))
|
||||
|
||||
def cancelJob(id: Ident, collective: Ident): F[JobCancelResult] = {
|
||||
def remove(job: RJob): F[JobCancelResult] =
|
||||
store.transact(RJob.delete(job.id)) *> JobCancelResult.removed.pure[F]
|
||||
|
Reference in New Issue
Block a user