mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Add a processing step to retrieve page counts
This commit is contained in:
@ -0,0 +1,2 @@
|
||||
ALTER TABLE "attachmentmeta"
|
||||
ADD COLUMN "page_count" smallint;
|
@ -0,0 +1,2 @@
|
||||
ALTER TABLE `attachmentmeta`
|
||||
ADD COLUMN (`page_count` SMALLINT);
|
@ -0,0 +1,2 @@
|
||||
ALTER TABLE "attachmentmeta"
|
||||
ADD COLUMN "page_count" smallint;
|
@ -13,17 +13,21 @@ case class RAttachmentMeta(
|
||||
id: Ident, //same as RAttachment.id
|
||||
content: Option[String],
|
||||
nerlabels: List[NerLabel],
|
||||
proposals: MetaProposalList
|
||||
proposals: MetaProposalList,
|
||||
pages: Option[Int]
|
||||
) {
|
||||
|
||||
def setContentIfEmpty(txt: Option[String]): RAttachmentMeta =
|
||||
if (content.forall(_.trim.isEmpty)) copy(content = txt)
|
||||
else this
|
||||
|
||||
def withPageCount(count: Option[Int]): RAttachmentMeta =
|
||||
copy(pages = count)
|
||||
}
|
||||
|
||||
object RAttachmentMeta {
|
||||
def empty(attachId: Ident) =
|
||||
RAttachmentMeta(attachId, None, Nil, MetaProposalList.empty)
|
||||
RAttachmentMeta(attachId, None, Nil, MetaProposalList.empty, None)
|
||||
|
||||
val table = fr"attachmentmeta"
|
||||
|
||||
@ -32,7 +36,8 @@ object RAttachmentMeta {
|
||||
val content = Column("content")
|
||||
val nerlabels = Column("nerlabels")
|
||||
val proposals = Column("itemproposals")
|
||||
val all = List(id, content, nerlabels, proposals)
|
||||
val pages = Column("page_count")
|
||||
val all = List(id, content, nerlabels, proposals, pages)
|
||||
}
|
||||
import Columns._
|
||||
|
||||
@ -40,7 +45,7 @@ object RAttachmentMeta {
|
||||
insertRow(
|
||||
table,
|
||||
all,
|
||||
fr"${v.id},${v.content},${v.nerlabels},${v.proposals}"
|
||||
fr"${v.id},${v.content},${v.nerlabels},${v.proposals},${v.pages}"
|
||||
).update.run
|
||||
|
||||
def exists(attachId: Ident): ConnectionIO[Boolean] =
|
||||
@ -84,6 +89,9 @@ object RAttachmentMeta {
|
||||
)
|
||||
).update.run
|
||||
|
||||
def updatePageCount(mid: Ident, pageCount: Option[Int]): ConnectionIO[Int] =
|
||||
updateRow(table, id.is(mid), pages.setTo(pageCount)).update.run
|
||||
|
||||
def delete(attachId: Ident): ConnectionIO[Int] =
|
||||
deleteFrom(table, id.is(attachId)).update.run
|
||||
}
|
||||
|
Reference in New Issue
Block a user