mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-03-28 17:55:06 +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
|
notifyJoex: Boolean
|
||||||
): F[UpdateResult]
|
): F[UpdateResult]
|
||||||
|
|
||||||
|
def reprocessAll(
|
||||||
|
items: NonEmptyList[Ident],
|
||||||
|
account: AccountId,
|
||||||
|
notifyJoex: Boolean
|
||||||
|
): F[UpdateResult]
|
||||||
|
|
||||||
/** Submits a task that finds all non-converted pdfs and triggers
|
/** Submits a task that finds all non-converted pdfs and triggers
|
||||||
* converting them using ocrmypdf. Each file is converted by a
|
* converting them using ocrmypdf. Each file is converted by a
|
||||||
* separate task.
|
* separate task.
|
||||||
@ -587,6 +593,20 @@ object OItem {
|
|||||||
_ <- OptionT.liftF(if (notifyJoex) joex.notifyAllNodes else ().pure[F])
|
_ <- OptionT.liftF(if (notifyJoex) joex.notifyAllNodes else ().pure[F])
|
||||||
} yield UpdateResult.success).getOrElse(UpdateResult.notFound)
|
} 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(
|
def convertAllPdf(
|
||||||
collective: Option[Ident],
|
collective: Option[Ident],
|
||||||
account: AccountId,
|
account: AccountId,
|
||||||
|
@ -2225,6 +2225,31 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/BasicResult"
|
$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}:
|
/sec/attachment/{id}:
|
||||||
delete:
|
delete:
|
||||||
|
@ -149,14 +149,13 @@ object ItemMultiRoutes {
|
|||||||
resp <- Ok(Conversions.basicResult(res, "Concerned equipment updated"))
|
resp <- Ok(Conversions.basicResult(res, "Concerned equipment updated"))
|
||||||
} yield resp
|
} yield resp
|
||||||
|
|
||||||
// case req @ POST -> Root / "reprocess" =>
|
case req @ POST -> Root / "reprocess" =>
|
||||||
// for {
|
for {
|
||||||
// data <- req.as[IdList]
|
json <- req.as[IdList]
|
||||||
// ids = data.ids.flatMap(s => Ident.fromString(s).toOption)
|
items <- readIds[F](json.ids)
|
||||||
// _ <- logger.fdebug(s"Re-process item ${id.id}")
|
res <- backend.item.reprocessAll(items, user.account, true)
|
||||||
// res <- backend.item.reprocess(id, ids, user.account, true)
|
resp <- Ok(Conversions.basicResult(res, "Re-process task(s) submitted."))
|
||||||
// resp <- Ok(Conversions.basicResult(res, "Re-process task submitted."))
|
} yield resp
|
||||||
// } yield resp
|
|
||||||
|
|
||||||
// case POST -> Root / "deleteAll" =>
|
// case POST -> Root / "deleteAll" =>
|
||||||
// for {
|
// for {
|
||||||
|
@ -114,5 +114,5 @@ multiUpdate flags ids change receive =
|
|||||||
in
|
in
|
||||||
Api.setConcEquipmentMultiple flags data receive
|
Api.setConcEquipmentMultiple flags data receive
|
||||||
|
|
||||||
_ ->
|
NoFormChange ->
|
||||||
Cmd.none
|
Cmd.none
|
||||||
|
Loading…
x
Reference in New Issue
Block a user