From d1606d6f16033c5c3eee8db5671bd8ecc856d1b3 Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Mon, 14 Dec 2020 13:41:26 +0100 Subject: [PATCH] Remove old commented code --- .../store/records/RAttachmentArchive.scala | 49 ---------------- .../store/records/RAttachmentPreview.scala | 57 ------------------- .../store/records/RAttachmentSource.scala | 51 ----------------- 3 files changed, 157 deletions(-) diff --git a/modules/store/src/main/scala/docspell/store/records/RAttachmentArchive.scala b/modules/store/src/main/scala/docspell/store/records/RAttachmentArchive.scala index ab97b9b2..f32c06fd 100644 --- a/modules/store/src/main/scala/docspell/store/records/RAttachmentArchive.scala +++ b/modules/store/src/main/scala/docspell/store/records/RAttachmentArchive.scala @@ -74,19 +74,6 @@ object RAttachmentArchive { attachId: Ident, collective: Ident ): ConnectionIO[Option[RAttachmentArchive]] = { -// val bId = RAttachment.Columns.id.prefix("b") -// val aId = Columns.id.prefix("a") -// val bItem = RAttachment.Columns.itemId.prefix("b") -// val iId = RItem.Columns.id.prefix("i") -// val iColl = RItem.Columns.cid.prefix("i") -// -// val from = table ++ fr"a INNER JOIN" ++ -// RAttachment.table ++ fr"b ON" ++ aId.is(bId) ++ -// fr"INNER JOIN" ++ RItem.table ++ fr"i ON" ++ bItem.is(iId) -// -// val where = and(aId.is(attachId), bId.is(attachId), iColl.is(collective)) -// -// selectSimple(all.map(_.prefix("a")), from, where).query[RAttachmentArchive].option val b = RAttachment.as("b") val a = RAttachmentArchive.as("a") val i = RItem.as("i") @@ -104,20 +91,6 @@ object RAttachmentArchive { messageIds: NonEmptyList[String], collective: Ident ): ConnectionIO[Vector[RAttachmentArchive]] = { -// val bId = RAttachment.Columns.id.prefix("b") -// val bItem = RAttachment.Columns.itemId.prefix("b") -// val aMsgId = Columns.messageId.prefix("a") -// val aId = Columns.id.prefix("a") -// val iId = RItem.Columns.id.prefix("i") -// val iColl = RItem.Columns.cid.prefix("i") -// -// val from = table ++ fr"a INNER JOIN" ++ -// RAttachment.table ++ fr"b ON" ++ aId.is(bId) ++ -// fr"INNER JOIN" ++ RItem.table ++ fr"i ON" ++ bItem.is(iId) -// -// val where = and(aMsgId.isIn(messageIds), iColl.is(collective)) -// -// selectSimple(all.map(_.prefix("a")), from, where).query[RAttachmentArchive].to[Vector] val b = RAttachment.as("b") val a = RAttachmentArchive.as("a") val i = RItem.as("i") @@ -135,24 +108,6 @@ object RAttachmentArchive { ): ConnectionIO[Vector[(RAttachmentArchive, FileMeta)]] = { import bitpeace.sql._ -// val aId = Columns.id.prefix("a") -// val afileMeta = fileId.prefix("a") -// val bPos = RAttachment.Columns.position.prefix("b") -// val bId = RAttachment.Columns.id.prefix("b") -// val bItem = RAttachment.Columns.itemId.prefix("b") -// val mId = RFileMeta.as("m").id.column -// -// val cols = all.map(_.prefix("a")) ++ RFileMeta.as("m").all.map(_.column).toList -// val from = table ++ fr"a INNER JOIN" ++ -// Fragment.const(RFileMeta.T.tableName) ++ fr"m ON" ++ afileMeta.is( -// mId -// ) ++ fr"INNER JOIN" ++ -// RAttachment.table ++ fr"b ON" ++ aId.is(bId) -// val where = bItem.is(id) -// -// (selectSimple(cols, from, where) ++ orderBy(bPos.asc)) -// .query[(RAttachmentArchive, FileMeta)] -// .to[Vector] val a = RAttachmentArchive.as("a") val b = RAttachment.as("b") val m = RFileMeta.as("m") @@ -170,14 +125,10 @@ object RAttachmentArchive { * no archive for the given attachment. */ def countEntries(attachId: Ident): ConnectionIO[Int] = -// val qFileId = selectSimple(Seq(fileId), table, id.is(attachId)) -// val q = selectCount(id, table, fileId.isSubquery(qFileId)) -// q.query[Int].unique Select( count(T.id).s, from(T), T.fileId.in(Select(T.fileId.s, from(T), T.id === attachId)) ).build.query[Int].unique - //TODO this looks strange, can be simplified } diff --git a/modules/store/src/main/scala/docspell/store/records/RAttachmentPreview.scala b/modules/store/src/main/scala/docspell/store/records/RAttachmentPreview.scala index 290efd50..24f6fc80 100644 --- a/modules/store/src/main/scala/docspell/store/records/RAttachmentPreview.scala +++ b/modules/store/src/main/scala/docspell/store/records/RAttachmentPreview.scala @@ -60,19 +60,6 @@ object RAttachmentPreview { attachId: Ident, collective: Ident ): ConnectionIO[Option[RAttachmentPreview]] = { -// val bId = RAttachment.Columns.id.prefix("b") -// val aId = Columns.id.prefix("a") -// val bItem = RAttachment.Columns.itemId.prefix("b") -// val iId = RItem.Columns.id.prefix("i") -// val iColl = RItem.Columns.cid.prefix("i") -// -// val from = table ++ fr"a INNER JOIN" ++ -// RAttachment.table ++ fr"b ON" ++ aId.is(bId) ++ -// fr"INNER JOIN" ++ RItem.table ++ fr"i ON" ++ bItem.is(iId) -// -// val where = and(aId.is(attachId), bId.is(attachId), iColl.is(collective)) -// -// selectSimple(all.map(_.prefix("a")), from, where).query[RAttachmentPreview].option val b = RAttachment.as("b") val a = RAttachmentPreview.as("a") val i = RItem.as("i") @@ -87,14 +74,6 @@ object RAttachmentPreview { } def findByItem(itemId: Ident): ConnectionIO[Vector[RAttachmentPreview]] = { -// val sId = Columns.id.prefix("s") -// val aId = RAttachment.Columns.id.prefix("a") -// val aItem = RAttachment.Columns.itemId.prefix("a") -// -// val from = table ++ fr"s INNER JOIN" ++ RAttachment.table ++ fr"a ON" ++ sId.is(aId) -// selectSimple(all.map(_.prefix("s")), from, aItem.is(itemId)) -// .query[RAttachmentPreview] -// .to[Vector] val s = RAttachmentPreview.as("s") val a = RAttachment.as("a") Select( @@ -109,25 +88,6 @@ object RAttachmentPreview { itemId: Ident, coll: Ident ): ConnectionIO[Option[RAttachmentPreview]] = { -// val sId = Columns.id.prefix("s") -// val aId = RAttachment.Columns.id.prefix("a") -// val aItem = RAttachment.Columns.itemId.prefix("a") -// val aPos = RAttachment.Columns.position.prefix("a") -// val iId = RItem.Columns.id.prefix("i") -// val iColl = RItem.Columns.cid.prefix("i") -// -// val from = -// table ++ fr"s INNER JOIN" ++ RAttachment.table ++ fr"a ON" ++ sId.is(aId) ++ -// fr"INNER JOIN" ++ RItem.table ++ fr"i ON" ++ iId.is(aItem) -// -// selectSimple( -// all.map(_.prefix("s")) ++ List(aPos), -// from, -// and(aItem.is(itemId), iColl.is(coll)) -// ) -// .query[(RAttachmentPreview, Int)] -// .to[Vector] -// .map(_.sortBy(_._2).headOption.map(_._1)) val s = RAttachmentPreview.as("s") val a = RAttachment.as("a") val i = RItem.as("i") @@ -149,22 +109,6 @@ object RAttachmentPreview { ): ConnectionIO[Vector[(RAttachmentPreview, FileMeta)]] = { import bitpeace.sql._ -// val aId = Columns.id.prefix("a") -// val afileMeta = fileId.prefix("a") -// val bPos = RAttachment.Columns.position.prefix("b") -// val bId = RAttachment.Columns.id.prefix("b") -// val bItem = RAttachment.Columns.itemId.prefix("b") -// val mId = RFileMeta.Columns.id.prefix("m") -// -// val cols = all.map(_.prefix("a")) ++ RFileMeta.Columns.all.map(_.prefix("m")) -// val from = table ++ fr"a INNER JOIN" ++ -// RFileMeta.table ++ fr"m ON" ++ afileMeta.is(mId) ++ fr"INNER JOIN" ++ -// RAttachment.table ++ fr"b ON" ++ aId.is(bId) -// val where = bItem.is(id) -// -// (selectSimple(cols, from, where) ++ orderBy(bPos.asc)) -// .query[(RAttachmentPreview, FileMeta)] -// .to[Vector] val a = RAttachmentPreview.as("a") val b = RAttachment.as("b") val m = RFileMeta.as("m") @@ -177,5 +121,4 @@ object RAttachmentPreview { b.itemId === id ).orderBy(b.position.asc).build.query[(RAttachmentPreview, FileMeta)].to[Vector] } - } diff --git a/modules/store/src/main/scala/docspell/store/records/RAttachmentSource.scala b/modules/store/src/main/scala/docspell/store/records/RAttachmentSource.scala index 4d94743b..20629645 100644 --- a/modules/store/src/main/scala/docspell/store/records/RAttachmentSource.scala +++ b/modules/store/src/main/scala/docspell/store/records/RAttachmentSource.scala @@ -70,19 +70,6 @@ object RAttachmentSource { from(s).innerJoin(a, a.id === s.id), a.id === attachId && a.fileId <> s.fileId ).build.query[Int].unique.map(_ > 0) - -// val sId = Columns.id.prefix("s") -// val sFile = Columns.fileId.prefix("s") -// val aId = RAttachment.Columns.id.prefix("a") -// val aFile = RAttachment.Columns.fileId.prefix("a") -// -// val from = table ++ fr"s INNER JOIN" ++ -// RAttachment.table ++ fr"a ON" ++ aId.is(sId) -// -// selectCount(aId, from, and(aId.is(attachId), aFile.isNot(sFile))) -// .query[Int] -// .unique -// .map(_ > 0) } def delete(attachId: Ident): ConnectionIO[Int] = @@ -92,19 +79,6 @@ object RAttachmentSource { attachId: Ident, collective: Ident ): ConnectionIO[Option[RAttachmentSource]] = { -// val bId = RAttachment.Columns.id.prefix("b") -// val aId = Columns.id.prefix("a") -// val bItem = RAttachment.Columns.itemId.prefix("b") -// val iId = RItem.Columns.id.prefix("i") -// val iColl = RItem.Columns.cid.prefix("i") -// -// val from = table ++ fr"a INNER JOIN" ++ -// RAttachment.table ++ fr"b ON" ++ aId.is(bId) ++ -// fr"INNER JOIN" ++ RItem.table ++ fr"i ON" ++ bItem.is(iId) -// -// val where = and(aId.is(attachId), bId.is(attachId), iColl.is(collective)) -// -// selectSimple(all.map(_.prefix("a")), from, where).query[RAttachmentSource].option val b = RAttachment.as("b") val a = RAttachmentSource.as("a") val i = RItem.as("i") @@ -119,15 +93,6 @@ object RAttachmentSource { } def findByItem(itemId: Ident): ConnectionIO[Vector[RAttachmentSource]] = { -// val sId = Columns.id.prefix("s") -// val aId = RAttachment.Columns.id.prefix("a") -// val aItem = RAttachment.Columns.itemId.prefix("a") -// -// val from = table ++ fr"s INNER JOIN" ++ RAttachment.table ++ fr"a ON" ++ sId.is(aId) -// selectSimple(all.map(_.prefix("s")), from, aItem.is(itemId)) -// .query[RAttachmentSource] -// .to[Vector] - val s = RAttachmentSource.as("s") val a = RAttachment.as("a") Select(select(s.all), from(s).innerJoin(a, a.id === s.id), a.itemId === itemId).build @@ -140,22 +105,6 @@ object RAttachmentSource { ): ConnectionIO[Vector[(RAttachmentSource, FileMeta)]] = { import bitpeace.sql._ -// val aId = Columns.id.prefix("a") -// val afileMeta = fileId.prefix("a") -// val bPos = RAttachment.Columns.position.prefix("b") -// val bId = RAttachment.Columns.id.prefix("b") -// val bItem = RAttachment.Columns.itemId.prefix("b") -// val mId = RFileMeta.Columns.id.prefix("m") -// -// val cols = all.map(_.prefix("a")) ++ RFileMeta.Columns.all.map(_.prefix("m")) -// val from = table ++ fr"a INNER JOIN" ++ -// RFileMeta.table ++ fr"m ON" ++ afileMeta.is(mId) ++ fr"INNER JOIN" ++ -// RAttachment.table ++ fr"b ON" ++ aId.is(bId) -// val where = bItem.is(id) -// -// (selectSimple(cols, from, where) ++ orderBy(bPos.asc)) -// .query[(RAttachmentSource, FileMeta)] -// .to[Vector] val a = RAttachmentSource.as("a") val b = RAttachment.as("b") val m = RFileMeta.as("m")