Minor improvements

This commit is contained in:
Eike Kettner
2020-11-09 21:16:53 +01:00
parent 29455d638c
commit 10305bc82d
4 changed files with 27 additions and 26 deletions

View File

@ -48,8 +48,8 @@ object MakePageCountTask {
private def pageCountExists[F[_]: Sync](ctx: Context[F, Args]): F[Boolean] =
ctx.store.transact(
RAttachmentMeta
.findById(ctx.args.attachment)
.map(_.flatMap(_.pages).exists(_ > 0))
.findPageCountById(ctx.args.attachment)
.map(_.exists(_ > 0))
)
}

View File

@ -56,22 +56,15 @@ object AllPreviewsTask {
private def createJobs[F[_]: Sync](
ctx: Context[F, Args]
)(ras: Chunk[RAttachment]): Stream[F, RJob] = {
val collectiveOrSystem = ctx.args.collective.getOrElse(DocspellSystem.taskGroup)
val collectiveOrSystem = {
val cid = ctx.args.collective.getOrElse(DocspellSystem.taskGroup)
AccountId(cid, DocspellSystem.user)
}
def mkJob(ra: RAttachment): F[RJob] =
for {
id <- Ident.randomId[F]
now <- Timestamp.current[F]
} yield RJob.newJob(
id,
MakePreviewArgs.taskName,
collectiveOrSystem,
JobFactory.makePreview(
MakePreviewArgs(ra.id, ctx.args.storeMode),
s"Create preview ${ra.id.id}/${ra.name.getOrElse("-")}",
now,
collectiveOrSystem,
Priority.Low,
Some(MakePreviewArgs.taskName / ra.id)
collectiveOrSystem.some
)
val jobs = ras.traverse(mkJob)