mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-03-25 16:45:05 +00:00
Send multiple items to reprocessing
This commit is contained in:
parent
26e89bf84e
commit
9193d7ca51
@ -152,6 +152,12 @@ trait OItem[F[_]] {
|
||||
notifyJoex: Boolean
|
||||
): F[UpdateResult]
|
||||
|
||||
def reprocessAll(
|
||||
items: NonEmptyList[Ident],
|
||||
account: AccountId,
|
||||
notifyJoex: Boolean
|
||||
): F[UpdateResult]
|
||||
|
||||
/** Submits a task that finds all non-converted pdfs and triggers
|
||||
* converting them using ocrmypdf. Each file is converted by a
|
||||
* separate task.
|
||||
@ -587,6 +593,20 @@ object OItem {
|
||||
_ <- OptionT.liftF(if (notifyJoex) joex.notifyAllNodes else ().pure[F])
|
||||
} yield UpdateResult.success).getOrElse(UpdateResult.notFound)
|
||||
|
||||
def reprocessAll(
|
||||
items: NonEmptyList[Ident],
|
||||
account: AccountId,
|
||||
notifyJoex: Boolean
|
||||
): F[UpdateResult] =
|
||||
UpdateResult.fromUpdate(for {
|
||||
items <- store.transact(RItem.filterItems(items, account.collective))
|
||||
jobs <- items
|
||||
.map(item => ReProcessItemArgs(item, Nil))
|
||||
.traverse(arg => JobFactory.reprocessItem[F](arg, account, Priority.Low))
|
||||
_ <- queue.insertAllIfNew(jobs)
|
||||
_ <- if (notifyJoex) joex.notifyAllNodes else ().pure[F]
|
||||
} yield items.size)
|
||||
|
||||
def convertAllPdf(
|
||||
collective: Option[Ident],
|
||||
account: AccountId,
|
||||
|
@ -2225,6 +2225,31 @@ paths:
|
||||
schema:
|
||||
$ref: "#/components/schemas/BasicResult"
|
||||
|
||||
/sec/items/reprocess:
|
||||
post:
|
||||
tags:
|
||||
- Item (Multi Edit)
|
||||
summary: Submit multiple items to re-processing
|
||||
description: |
|
||||
Given a list of item-ids, submits all these items for
|
||||
reprocessing. All attachments of these items will be
|
||||
reprocessed. Item metadata is not changed.
|
||||
security:
|
||||
- authTokenHeader: []
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/IdList"
|
||||
|
||||
responses:
|
||||
200:
|
||||
description: Ok
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/BasicResult"
|
||||
|
||||
|
||||
/sec/attachment/{id}:
|
||||
delete:
|
||||
|
@ -149,14 +149,13 @@ object ItemMultiRoutes {
|
||||
resp <- Ok(Conversions.basicResult(res, "Concerned equipment updated"))
|
||||
} yield resp
|
||||
|
||||
// case req @ POST -> Root / "reprocess" =>
|
||||
// for {
|
||||
// data <- req.as[IdList]
|
||||
// ids = data.ids.flatMap(s => Ident.fromString(s).toOption)
|
||||
// _ <- logger.fdebug(s"Re-process item ${id.id}")
|
||||
// res <- backend.item.reprocess(id, ids, user.account, true)
|
||||
// resp <- Ok(Conversions.basicResult(res, "Re-process task submitted."))
|
||||
// } yield resp
|
||||
case req @ POST -> Root / "reprocess" =>
|
||||
for {
|
||||
json <- req.as[IdList]
|
||||
items <- readIds[F](json.ids)
|
||||
res <- backend.item.reprocessAll(items, user.account, true)
|
||||
resp <- Ok(Conversions.basicResult(res, "Re-process task(s) submitted."))
|
||||
} yield resp
|
||||
|
||||
// case POST -> Root / "deleteAll" =>
|
||||
// for {
|
||||
|
@ -114,5 +114,5 @@ multiUpdate flags ids change receive =
|
||||
in
|
||||
Api.setConcEquipmentMultiple flags data receive
|
||||
|
||||
_ ->
|
||||
NoFormChange ->
|
||||
Cmd.none
|
||||
|
Loading…
x
Reference in New Issue
Block a user