mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-05 10:59: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,
|
collective: Ident,
|
||||||
excludeFileMeta: Set[Ident]
|
excludeFileMeta: Set[Ident]
|
||||||
): ConnectionIO[Vector[RItem]] = {
|
): ConnectionIO[Vector[RItem]] = {
|
||||||
val m1 = RFileMeta.as("m1")
|
val m1 = RFileMeta.as("m1")
|
||||||
val m2 = RFileMeta.as("m2")
|
val m2 = RFileMeta.as("m2")
|
||||||
val m3 = RFileMeta.as("m3")
|
val m3 = RFileMeta.as("m3")
|
||||||
val i = RItem.as("i")
|
val i = RItem.as("i")
|
||||||
val a = RAttachment.as("a")
|
val a = RAttachment.as("a")
|
||||||
val s = RAttachmentSource.as("s")
|
val s = RAttachmentSource.as("s")
|
||||||
val r = RAttachmentArchive.as("r")
|
val r = RAttachmentArchive.as("r")
|
||||||
|
val fms = Nel.of(m1, m2, m3)
|
||||||
Select(
|
val qq =
|
||||||
select(i.all),
|
Select(
|
||||||
from(i)
|
select(i.all),
|
||||||
.innerJoin(a, a.itemId === i.id)
|
from(i)
|
||||||
.innerJoin(s, s.id === a.id)
|
.innerJoin(a, a.itemId === i.id)
|
||||||
.innerJoin(m1, m1.id === a.fileId)
|
.innerJoin(s, s.id === a.id)
|
||||||
.innerJoin(m2, m2.id === s.fileId)
|
.innerJoin(m1, m1.id === a.fileId)
|
||||||
.leftJoin(r, r.id === a.id)
|
.innerJoin(m2, m2.id === s.fileId)
|
||||||
.leftJoin(m3, m3.id === r.fileId),
|
.leftJoin(r, r.id === a.id)
|
||||||
where(
|
.leftJoin(m3, m3.id === r.fileId),
|
||||||
i.cid === collective &&
|
where(
|
||||||
(m1.checksum === checksum || m2.checksum === checksum || m3.checksum === checksum) &&?
|
i.cid === collective &&
|
||||||
Nel
|
Condition.Or(fms.map(m => m.checksum === checksum)) &&?
|
||||||
.fromList(excludeFileMeta.toList)
|
Nel
|
||||||
.map(excl => m1.id.notIn(excl) && m2.id.notIn(excl) && m3.id.notIn(excl))
|
.fromList(excludeFileMeta.toList)
|
||||||
)
|
.map(excl => Condition.And(fms.map(m => m.id.isNull || m.id.notIn(excl))))
|
||||||
).distinct.build.query[RItem].to[Vector]
|
)
|
||||||
|
).distinct.build
|
||||||
|
logger.debug(s"FindByChecksum: $qq")
|
||||||
|
qq.query[RItem].to[Vector]
|
||||||
}
|
}
|
||||||
|
|
||||||
final case class NameAndNotes(
|
final case class NameAndNotes(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user