mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Refactoring some code into separate files
This commit is contained in:
@ -3,12 +3,11 @@ package docspell.backend.ops
|
||||
import cats.effect._
|
||||
import cats.implicits._
|
||||
import fs2.Stream
|
||||
|
||||
import docspell.backend.JobFactory
|
||||
import docspell.backend.ops.OItemSearch._
|
||||
import docspell.common._
|
||||
import docspell.ftsclient._
|
||||
import docspell.store.queries.{QFolder, QItem}
|
||||
import docspell.store.queries.{QFolder, QItem, SelectedItem}
|
||||
import docspell.store.queue.JobQueue
|
||||
import docspell.store.records.RJob
|
||||
import docspell.store.{Store, qb}
|
||||
@ -112,15 +111,15 @@ object OFulltext {
|
||||
ftsItems = ftsR.results.groupBy(_.itemId)
|
||||
select =
|
||||
ftsItems.values
|
||||
.map(_.sortBy(-_.score).head)
|
||||
.map(r => QItem.SelectedItem(r.itemId, r.score))
|
||||
.map(_.minBy(-_.score))
|
||||
.map(r => SelectedItem(r.itemId, r.score))
|
||||
.toSet
|
||||
itemsWithTags <-
|
||||
store
|
||||
.transact(
|
||||
QItem.findItemsWithTags(
|
||||
account.collective,
|
||||
QItem.findSelectedItems(QItem.Query.empty(account), maxNoteLen, select)
|
||||
QItem.findSelectedItems(Query.empty(account), maxNoteLen, select)
|
||||
)
|
||||
)
|
||||
.take(batch.limit.toLong)
|
||||
@ -227,10 +226,9 @@ object OFulltext {
|
||||
): PartialFunction[A, (A, FtsData)] = {
|
||||
case a if ftrItems.contains(ItemId[A].itemId(a)) =>
|
||||
val ftsDataItems = ftrItems
|
||||
.get(ItemId[A].itemId(a))
|
||||
.getOrElse(Nil)
|
||||
.getOrElse(ItemId[A].itemId(a), Nil)
|
||||
.map(im =>
|
||||
FtsDataItem(im.score, im.data, ftr.highlight.get(im.id).getOrElse(Nil))
|
||||
FtsDataItem(im.score, im.data, ftr.highlight.getOrElse(im.id, Nil))
|
||||
)
|
||||
(a, FtsData(ftr.maxScore, ftr.count, ftr.qtime, ftsDataItems))
|
||||
}
|
||||
|
@ -4,16 +4,14 @@ import cats.data.NonEmptyList
|
||||
import cats.data.OptionT
|
||||
import cats.effect.{Effect, Resource}
|
||||
import cats.implicits._
|
||||
|
||||
import docspell.backend.JobFactory
|
||||
import docspell.common._
|
||||
import docspell.ftsclient.FtsClient
|
||||
import docspell.store.UpdateResult
|
||||
import docspell.store.queries.{QAttachment, QItem}
|
||||
import docspell.store.queries.{QAttachment, QItem, QMoveAttachment}
|
||||
import docspell.store.queue.JobQueue
|
||||
import docspell.store.records._
|
||||
import docspell.store.{AddResult, Store}
|
||||
|
||||
import doobie.implicits._
|
||||
import org.log4s.getLogger
|
||||
|
||||
@ -206,7 +204,7 @@ object OItem {
|
||||
target: Ident
|
||||
): F[AddResult] =
|
||||
store
|
||||
.transact(QItem.moveAttachmentBefore(itemId, source, target))
|
||||
.transact(QMoveAttachment.moveAttachmentBefore(itemId, source, target))
|
||||
.attempt
|
||||
.map(AddResult.fromUpdate)
|
||||
|
||||
|
@ -9,7 +9,7 @@ import docspell.backend.ops.OItemSearch._
|
||||
import docspell.common._
|
||||
import docspell.store.queries.{QAttachment, QItem}
|
||||
import docspell.store.records._
|
||||
import docspell.store.{Store, qb}
|
||||
import docspell.store._
|
||||
|
||||
import bitpeace.{FileMeta, RangeDef}
|
||||
import doobie.implicits._
|
||||
@ -53,26 +53,26 @@ trait OItemSearch[F[_]] {
|
||||
|
||||
object OItemSearch {
|
||||
|
||||
type CustomValue = QItem.CustomValue
|
||||
val CustomValue = QItem.CustomValue
|
||||
type CustomValue = queries.CustomValue
|
||||
val CustomValue = queries.CustomValue
|
||||
|
||||
type Query = QItem.Query
|
||||
val Query = QItem.Query
|
||||
type Query = queries.Query
|
||||
val Query = queries.Query
|
||||
|
||||
type Batch = qb.Batch
|
||||
val Batch = docspell.store.qb.Batch
|
||||
|
||||
type ListItem = QItem.ListItem
|
||||
val ListItem = QItem.ListItem
|
||||
type ListItem = queries.ListItem
|
||||
val ListItem = queries.ListItem
|
||||
|
||||
type ListItemWithTags = QItem.ListItemWithTags
|
||||
val ListItemWithTags = QItem.ListItemWithTags
|
||||
type ListItemWithTags = queries.ListItemWithTags
|
||||
val ListItemWithTags = queries.ListItemWithTags
|
||||
|
||||
type ItemFieldValue = QItem.ItemFieldValue
|
||||
val ItemFieldValue = QItem.ItemFieldValue
|
||||
type ItemFieldValue = queries.ItemFieldValue
|
||||
val ItemFieldValue = queries.ItemFieldValue
|
||||
|
||||
type ItemData = QItem.ItemData
|
||||
val ItemData = QItem.ItemData
|
||||
type ItemData = queries.ItemData
|
||||
val ItemData = queries.ItemData
|
||||
|
||||
trait BinaryData[F[_]] {
|
||||
def data: Stream[F, Byte]
|
||||
|
Reference in New Issue
Block a user