mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Store tags guessed with classifier in database
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
package docspell.store.records
|
||||
|
||||
import cats.data.NonEmptyList
|
||||
//import cats.implicits._
|
||||
|
||||
import docspell.common._
|
||||
import docspell.store.qb.DSL._
|
||||
@ -39,22 +38,23 @@ object RItemProposal {
|
||||
fr"${v.itemId},${v.classifyProposals},${v.classifyTags},${v.created}"
|
||||
)
|
||||
|
||||
def update(v: RItemProposal): ConnectionIO[Int] =
|
||||
DML.update(
|
||||
T,
|
||||
T.itemId === v.itemId,
|
||||
DML.set(
|
||||
T.classifyProposals.setTo(v.classifyProposals),
|
||||
T.classifyTags.setTo(v.classifyTags)
|
||||
)
|
||||
)
|
||||
|
||||
def deleteByItem(itemId: Ident): ConnectionIO[Int] =
|
||||
DML.delete(T, T.itemId === itemId)
|
||||
|
||||
def createNew(itemId: Ident, proposals: MetaProposalList): ConnectionIO[Int] =
|
||||
for {
|
||||
now <- Timestamp.current[ConnectionIO]
|
||||
value = RItemProposal(itemId, proposals, Nil, now)
|
||||
n <- insert(value)
|
||||
} yield n
|
||||
|
||||
def exists(itemId: Ident): ConnectionIO[Boolean] =
|
||||
Select(select(countAll), from(T), T.itemId === itemId).build
|
||||
.query[Int]
|
||||
.unique
|
||||
.map(_ > 0)
|
||||
|
||||
def updateProposals(itemId: Ident, proposals: MetaProposalList): ConnectionIO[Int] =
|
||||
DML.update(T, T.itemId === itemId, DML.set(T.classifyProposals.setTo(proposals)))
|
||||
}
|
||||
|
Reference in New Issue
Block a user