mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 18:38:26 +00:00
Exclude tags w/o category from classifying; remove obsolete models
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
package docspell.store.records
|
||||
|
||||
import cats.effect._
|
||||
import cats.data.NonEmptyList
|
||||
import cats.effect._
|
||||
import cats.implicits._
|
||||
|
||||
import docspell.common._
|
||||
@ -63,6 +63,17 @@ object RClassifierModel {
|
||||
else 0.pure[ConnectionIO]
|
||||
} yield n + k
|
||||
|
||||
def deleteById(id: Ident): ConnectionIO[Int] =
|
||||
DML.delete(T, T.id === id)
|
||||
|
||||
def deleteAll(ids: List[Ident]): ConnectionIO[Int] =
|
||||
NonEmptyList.fromList(ids) match {
|
||||
case Some(nel) =>
|
||||
DML.delete(T, T.id.in(nel))
|
||||
case None =>
|
||||
0.pure[ConnectionIO]
|
||||
}
|
||||
|
||||
def findByName(cid: Ident, name: String): ConnectionIO[Option[RClassifierModel]] =
|
||||
Select(select(T.all), from(T), T.cid === cid && T.name === name).build
|
||||
.query[RClassifierModel]
|
||||
@ -75,4 +86,5 @@ object RClassifierModel {
|
||||
Select(select(T.all), from(T), T.cid === cid && T.name.in(names)).build
|
||||
.query[RClassifierModel]
|
||||
.to[List]
|
||||
|
||||
}
|
||||
|
@ -148,11 +148,11 @@ object RTag {
|
||||
).orderBy(T.name.asc).build.query[RTag].to[List]
|
||||
}
|
||||
|
||||
def listCategories(coll: Ident, fallback: String): ConnectionIO[List[String]] =
|
||||
def listCategories(coll: Ident): ConnectionIO[List[String]] =
|
||||
Select(
|
||||
coalesce(T.category.s, lit(fallback)).s,
|
||||
T.category.s,
|
||||
from(T),
|
||||
T.cid === coll
|
||||
T.cid === coll && T.category.isNotNull
|
||||
).distinct.build.query[String].to[List]
|
||||
|
||||
def delete(tagId: Ident, coll: Ident): ConnectionIO[Int] =
|
||||
|
Reference in New Issue
Block a user