mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-04 18:39:33 +00:00
Merge pull request #534 from eikek/duplicate-check
Fixing find-by-checksum with exclusions
This commit is contained in:
commit
84d160aa38
@ -481,31 +481,34 @@ object QItem {
|
||||
collective: Ident,
|
||||
excludeFileMeta: Set[Ident]
|
||||
): ConnectionIO[Vector[RItem]] = {
|
||||
val m1 = RFileMeta.as("m1")
|
||||
val m2 = RFileMeta.as("m2")
|
||||
val m3 = RFileMeta.as("m3")
|
||||
val i = RItem.as("i")
|
||||
val a = RAttachment.as("a")
|
||||
val s = RAttachmentSource.as("s")
|
||||
val r = RAttachmentArchive.as("r")
|
||||
|
||||
Select(
|
||||
select(i.all),
|
||||
from(i)
|
||||
.innerJoin(a, a.itemId === i.id)
|
||||
.innerJoin(s, s.id === a.id)
|
||||
.innerJoin(m1, m1.id === a.fileId)
|
||||
.innerJoin(m2, m2.id === s.fileId)
|
||||
.leftJoin(r, r.id === a.id)
|
||||
.leftJoin(m3, m3.id === r.fileId),
|
||||
where(
|
||||
i.cid === collective &&
|
||||
(m1.checksum === checksum || m2.checksum === checksum || m3.checksum === checksum) &&?
|
||||
Nel
|
||||
.fromList(excludeFileMeta.toList)
|
||||
.map(excl => m1.id.notIn(excl) && m2.id.notIn(excl) && m3.id.notIn(excl))
|
||||
)
|
||||
).distinct.build.query[RItem].to[Vector]
|
||||
val m1 = RFileMeta.as("m1")
|
||||
val m2 = RFileMeta.as("m2")
|
||||
val m3 = RFileMeta.as("m3")
|
||||
val i = RItem.as("i")
|
||||
val a = RAttachment.as("a")
|
||||
val s = RAttachmentSource.as("s")
|
||||
val r = RAttachmentArchive.as("r")
|
||||
val fms = Nel.of(m1, m2, m3)
|
||||
val qq =
|
||||
Select(
|
||||
select(i.all),
|
||||
from(i)
|
||||
.innerJoin(a, a.itemId === i.id)
|
||||
.innerJoin(s, s.id === a.id)
|
||||
.innerJoin(m1, m1.id === a.fileId)
|
||||
.innerJoin(m2, m2.id === s.fileId)
|
||||
.leftJoin(r, r.id === a.id)
|
||||
.leftJoin(m3, m3.id === r.fileId),
|
||||
where(
|
||||
i.cid === collective &&
|
||||
Condition.Or(fms.map(m => m.checksum === checksum)) &&?
|
||||
Nel
|
||||
.fromList(excludeFileMeta.toList)
|
||||
.map(excl => Condition.And(fms.map(m => m.id.isNull || m.id.notIn(excl))))
|
||||
)
|
||||
).distinct.build
|
||||
logger.debug(s"FindByChecksum: $qq")
|
||||
qq.query[RItem].to[Vector]
|
||||
}
|
||||
|
||||
final case class NameAndNotes(
|
||||
|
Loading…
x
Reference in New Issue
Block a user