mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-04 10:29:34 +00:00
Add a route to trigger the convert-all-pdf task for a collective
This commit is contained in:
parent
69674eb485
commit
081c4da903
@ -8,6 +8,27 @@ import docspell.store.records.RJob
|
||||
|
||||
object JobFactory {
|
||||
|
||||
def convertAllPdfs[F[_]: Sync](
|
||||
collective: Option[Ident],
|
||||
account: AccountId,
|
||||
prio: Priority
|
||||
): F[RJob] =
|
||||
for {
|
||||
id <- Ident.randomId[F]
|
||||
now <- Timestamp.current[F]
|
||||
job = RJob.newJob(
|
||||
id,
|
||||
ConvertAllPdfArgs.taskName,
|
||||
account.collective,
|
||||
ConvertAllPdfArgs(collective),
|
||||
s"Convert all pdfs not yet converted",
|
||||
now,
|
||||
account.user,
|
||||
prio,
|
||||
None
|
||||
)
|
||||
} yield job
|
||||
|
||||
def reprocessItem[F[_]: Sync](
|
||||
args: ReProcessItemArgs,
|
||||
account: AccountId,
|
||||
|
@ -57,6 +57,11 @@ trait OUpload[F[_]] {
|
||||
notifyJoex: Boolean
|
||||
): F[OUpload.UploadResult]
|
||||
|
||||
def convertAllPdf(
|
||||
collective: Option[Ident],
|
||||
account: AccountId,
|
||||
notifyJoex: Boolean
|
||||
): F[OUpload.UploadResult]
|
||||
}
|
||||
|
||||
object OUpload {
|
||||
@ -187,6 +192,16 @@ object OUpload {
|
||||
res <- OptionT.liftF(submitJobs(notifyJoex)(Vector(job)))
|
||||
} yield res).getOrElse(UploadResult.noItem)
|
||||
|
||||
def convertAllPdf(
|
||||
collective: Option[Ident],
|
||||
account: AccountId,
|
||||
notifyJoex: Boolean
|
||||
): F[OUpload.UploadResult] =
|
||||
for {
|
||||
job <- JobFactory.convertAllPdfs(collective, account, Priority.Low)
|
||||
res <- submitJobs(notifyJoex)(Vector(job))
|
||||
} yield res
|
||||
|
||||
private def submitJobs(
|
||||
notifyJoex: Boolean
|
||||
)(jobs: Vector[RJob]): F[OUpload.UploadResult] =
|
||||
|
@ -31,6 +31,13 @@ object ItemRoutes {
|
||||
import dsl._
|
||||
|
||||
HttpRoutes.of {
|
||||
case POST -> Root / "convertallpdfs" =>
|
||||
for {
|
||||
res <-
|
||||
backend.upload.convertAllPdf(user.account.collective.some, user.account, true)
|
||||
resp <- Ok(Conversions.basicResult(res))
|
||||
} yield resp
|
||||
|
||||
case req @ POST -> Root / "search" =>
|
||||
for {
|
||||
mask <- req.as[ItemSearch]
|
||||
|
Loading…
x
Reference in New Issue
Block a user