From 61c01ad79b9aa5628d0bfba31f2e8ca80d8a0e12 Mon Sep 17 00:00:00 2001 From: eikek Date: Sun, 7 Nov 2021 22:39:44 +0100 Subject: [PATCH] Use job group instead of parsing the task arguments --- .../src/main/scala/docspell/backend/msg/JobDone.scala | 8 +++++++- .../scala/docspell/joex/scheduler/SchedulerImpl.scala | 2 +- .../main/scala/docspell/restserver/Subscriptions.scala | 8 ++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/backend/src/main/scala/docspell/backend/msg/JobDone.scala b/modules/backend/src/main/scala/docspell/backend/msg/JobDone.scala index 9b09b8f1..0ac701c3 100644 --- a/modules/backend/src/main/scala/docspell/backend/msg/JobDone.scala +++ b/modules/backend/src/main/scala/docspell/backend/msg/JobDone.scala @@ -13,7 +13,13 @@ import io.circe.generic.semiauto.{deriveDecoder, deriveEncoder} import io.circe.{Decoder, Encoder} /** Message to notify about finished jobs. They have a final state. */ -final case class JobDone(jobId: Ident, task: Ident, args: String, state: JobState) +final case class JobDone( + jobId: Ident, + group: Ident, + task: Ident, + args: String, + state: JobState +) object JobDone { implicit val jsonDecoder: Decoder[JobDone] = deriveDecoder[JobDone] diff --git a/modules/joex/src/main/scala/docspell/joex/scheduler/SchedulerImpl.scala b/modules/joex/src/main/scala/docspell/joex/scheduler/SchedulerImpl.scala index e38a282b..b403b59c 100644 --- a/modules/joex/src/main/scala/docspell/joex/scheduler/SchedulerImpl.scala +++ b/modules/joex/src/main/scala/docspell/joex/scheduler/SchedulerImpl.scala @@ -204,7 +204,7 @@ final class SchedulerImpl[F[_]: Async]( _ <- QJob.setFinalState(job.id, finalState, store) _ <- pubSub.publish1IgnoreErrors( JobDone.topic, - JobDone(job.id, job.task, job.args, finalState) + JobDone(job.id, job.group, job.task, job.args, finalState) ) } yield () diff --git a/modules/restserver/src/main/scala/docspell/restserver/Subscriptions.scala b/modules/restserver/src/main/scala/docspell/restserver/Subscriptions.scala index a574f0f2..09d5e216 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/Subscriptions.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/Subscriptions.scala @@ -8,10 +8,8 @@ package docspell.restserver import fs2.Stream import fs2.concurrent.Topic - import docspell.backend.msg.JobDone -import docspell.common._ -import docspell.common.syntax.StringSyntax._ +import docspell.common.ProcessItemArgs import docspell.pubsub.api.PubSubT import docspell.restserver.ws.OutputEvent @@ -29,7 +27,5 @@ object Subscriptions { pubSub .subscribe(JobDone.topic) .filter(m => m.body.task == ProcessItemArgs.taskName) - .map(m => m.body.args.parseJsonAs[ProcessItemArgs]) - .collect { case Right(a) => OutputEvent.ItemProcessed(a.meta.collective) } - + .map(m => OutputEvent.ItemProcessed(m.body.group)) }