Update scalafmt settings

This commit is contained in:
eikek
2021-09-22 17:23:24 +02:00
parent c37f1d7c31
commit 9013f2de5b
277 changed files with 1579 additions and 1615 deletions

View File

@ -27,14 +27,14 @@ object AddResult {
)
case object Success extends AddResult {
def toEither = Right(())
def toEither = Right(())
val isSuccess = true
def fold[A](fa: Success.type => A, fb: EntityExists => A, fc: Failure => A): A =
fa(this)
}
case class EntityExists(msg: String) extends AddResult {
def toEither = Left(new Exception(msg))
def toEither = Left(new Exception(msg))
val isSuccess = false
def fold[A](fa: Success.type => A, fb: EntityExists => A, fc: Failure => A): A =
fb(this)
@ -45,7 +45,7 @@ object AddResult {
def entityExists(msg: String): AddResult = EntityExists(msg)
case class Failure(ex: Throwable) extends AddResult {
def toEither = Left(ex)
def toEither = Left(ex)
val isSuccess = false
def fold[A](fa: Success.type => A, fb: EntityExists => A, fc: Failure => A): A =
fc(this)

View File

@ -36,7 +36,7 @@ object Store {
chunkSize: Int,
connectEC: ExecutionContext
): Resource[F, Store[F]] = {
val acquire = Sync[F].delay(new HikariDataSource())
val acquire = Sync[F].delay(new HikariDataSource())
val free: HikariDataSource => F[Unit] = ds => Sync[F].delay(ds.close())
for {

View File

@ -13,12 +13,12 @@ sealed trait UpdateResult
object UpdateResult {
case object Success extends UpdateResult
case object NotFound extends UpdateResult
case object Success extends UpdateResult
case object NotFound extends UpdateResult
final case class Failure(ex: Throwable) extends UpdateResult
def success: UpdateResult = Success
def notFound: UpdateResult = NotFound
def success: UpdateResult = Success
def notFound: UpdateResult = NotFound
def failure(ex: Throwable): UpdateResult = Failure(ex)
def fromUpdateRows(n: Int): UpdateResult =

View File

@ -22,7 +22,7 @@ final private[file] class AttributeStore[F[_]: Sync](xa: Transactor[F])
def saveAttr(id: BinaryId, attrs: F[BinaryAttributes]): F[Unit] =
for {
now <- Timestamp.current[F]
a <- attrs
a <- attrs
fm = RFileMeta(
Ident.unsafe(id.id),
now,

View File

@ -42,8 +42,8 @@ object FileStore {
chunkSize: Int
): FileStore[F] = {
val attrStore = new AttributeStore[F](xa)
val cfg = JdbcStoreConfig("filechunk", chunkSize, TikaContentTypeDetect.default)
val binStore = GenericJdbcStore[F](ds, Log4sLogger[F](logger), cfg, attrStore)
val cfg = JdbcStoreConfig("filechunk", chunkSize, TikaContentTypeDetect.default)
val binStore = GenericJdbcStore[F](ds, Log4sLogger[F](logger), cfg, attrStore)
new Impl[F](binStore, attrStore)
}

View File

@ -33,7 +33,7 @@ final class StoreImpl[F[_]: Async](
def add(insert: ConnectionIO[Int], exists: ConnectionIO[Boolean]): F[AddResult] =
for {
save <- transact(insert).attempt
save <- transact(insert).attempt
exist <- save.swap.traverse(ex => transact(exists).map(b => (ex, b)))
} yield exist.swap match {
case Right(_) => AddResult.Success

View File

@ -45,8 +45,8 @@ object DBFunction {
sealed trait Operator
object Operator {
case object Plus extends Operator
case object Plus extends Operator
case object Minus extends Operator
case object Mult extends Operator
case object Mult extends Operator
}
}

View File

@ -81,7 +81,7 @@ object FromExpr {
sealed trait Join
object Join {
final case class InnerJoin(table: Relation, cond: Condition) extends Join
final case class LeftJoin(table: Relation, cond: Condition) extends Join
final case class LeftJoin(table: Relation, cond: Condition) extends Join
}
}

View File

@ -10,13 +10,13 @@ sealed trait Operator
object Operator {
case object Eq extends Operator
case object LowerEq extends Operator
case object Neq extends Operator
case object Gt extends Operator
case object Lt extends Operator
case object Gte extends Operator
case object Lte extends Operator
case object Eq extends Operator
case object LowerEq extends Operator
case object Neq extends Operator
case object Gt extends Operator
case object Lt extends Operator
case object Gte extends Operator
case object Lte extends Operator
case object LowerLike extends Operator
}

View File

@ -20,7 +20,7 @@ object OrderBy {
sealed trait OrderType
object OrderType {
case object Asc extends OrderType
case object Asc extends OrderType
case object Desc extends OrderType
}
}

View File

@ -12,17 +12,14 @@ import docspell.store.qb.impl.SelectBuilder
import doobie._
/** A sql select statement that allows to change certain parts of the query.
*/
/** A sql select statement that allows to change certain parts of the query. */
sealed trait Select {
/** Builds the sql select statement into a doobie fragment.
*/
/** Builds the sql select statement into a doobie fragment. */
def build: Fragment =
SelectBuilder(this)
/** When using this as a sub-select, an alias is required.
*/
/** When using this as a sub-select, an alias is required. */
def as(alias: String): SelectExpr.SelectQuery =
SelectExpr.SelectQuery(this, Some(alias))

View File

@ -95,8 +95,8 @@ object ItemQueryGenerator {
}
case Expr.SimpleExpr(op, Property.DateProperty(attr, value)) =>
val dt = dateToTimestamp(today)(value)
val col = timestampColumn(tables)(attr)
val dt = dateToTimestamp(today)(value)
val col = timestampColumn(tables)(attr)
val noLikeOp = if (op == Operator.Like) Operator.Eq else op
Condition.CompareFVal(col, makeOp(noLikeOp), dt)
@ -286,7 +286,7 @@ object ItemQueryGenerator {
private def itemsWithCustomField(
sel: RCustomField.Table => Condition
)(coll: Ident, op: QOp, value: String): Select = {
val cf = RCustomField.as("cf")
val cf = RCustomField.as("cf")
val cfv = RCustomFieldValue.as("cfv")
val baseSelect =

View File

@ -14,10 +14,10 @@ import _root_.doobie.implicits._
import _root_.doobie.{Query => _, _}
object ConditionBuilder {
val or = fr" OR"
val and = fr" AND"
val comma = fr","
val parenOpen = Fragment.const0("(")
val or = fr" OR"
val and = fr" AND"
val comma = fr","
val parenOpen = Fragment.const0("(")
val parenClose = Fragment.const0(")")
final def reduce(c: Condition): Condition =
@ -70,7 +70,7 @@ object ConditionBuilder {
final def build(expr: Condition): Fragment =
reduce(expr) match {
case c @ Condition.CompareVal(col, op, value) =>
val opFrag = operator(op)
val opFrag = operator(op)
val valFrag = buildValue(value)(c.P)
val colFrag = op match {
case Operator.LowerLike =>
@ -83,7 +83,7 @@ object ConditionBuilder {
colFrag ++ opFrag ++ valFrag
case c @ Condition.CompareFVal(dbf, op, value) =>
val opFrag = operator(op)
val opFrag = operator(op)
val valFrag = buildValue(value)(c.P)
val dbfFrag = op match {
case Operator.LowerLike =>

View File

@ -14,11 +14,11 @@ import _root_.doobie.implicits._
import _root_.doobie.{Query => _, _}
object SelectBuilder {
val comma = fr","
val asc = fr" ASC"
val desc = fr" DESC"
val comma = fr","
val asc = fr" ASC"
val desc = fr" DESC"
val intersect = fr" INTERSECT"
val union = fr" UNION ALL"
val union = fr" UNION ALL"
def apply(q: Select): Fragment =
build(q)

View File

@ -11,10 +11,10 @@ import docspell.store.qb.Column
import docspell.store.qb.TableDef
final case class AttachCountTable(aliasName: String) extends TableDef {
val tableName = "attachs"
val tableName = "attachs"
val alias: Option[String] = Some(aliasName)
val num = Column[Int]("num", this)
val num = Column[Int]("num", this)
val itemId = Column[Ident]("item_id", this)
def as(alias: String): AttachCountTable =

View File

@ -24,11 +24,11 @@ import doobie._
object QAttachment {
private[this] val logger = org.log4s.getLogger
private val a = RAttachment.as("a")
private val a = RAttachment.as("a")
private val item = RItem.as("i")
private val am = RAttachmentMeta.as("am")
private val c = RCollective.as("c")
private val im = RItemProposal.as("im")
private val am = RAttachmentMeta.as("am")
private val c = RCollective.as("c")
private val im = RItemProposal.as("im")
def deletePreview[F[_]: Sync](store: Store[F])(attachId: Ident): F[Int] = {
val findPreview =
@ -100,7 +100,7 @@ object QAttachment {
def deleteArchive[F[_]: Sync](store: Store[F])(attachId: Ident): F[Int] =
(for {
aa <- OptionT(store.transact(RAttachmentArchive.findById(attachId)))
n <- OptionT.liftF(store.transact(RAttachmentArchive.deleteAll(aa.fileId)))
n <- OptionT.liftF(store.transact(RAttachmentArchive.deleteAll(aa.fileId)))
_ <- OptionT.liftF(
Stream
.emit(aa.fileId)
@ -118,8 +118,8 @@ object QAttachment {
_ <- logger.finfo[F](
s"Have ${ras.size} attachments to delete. Must first delete archive entries"
)
a <- ras.traverse(a => deleteArchive(store)(a.id))
_ <- logger.fdebug[F](s"Deleted ${a.sum} archive entries")
a <- ras.traverse(a => deleteArchive(store)(a.id))
_ <- logger.fdebug[F](s"Deleted ${a.sum} archive entries")
ns <- ras.traverse(deleteAttachment[F](store))
} yield ns.sum

View File

@ -18,12 +18,12 @@ import doobie.implicits._
object QCollective {
private val ti = RTagItem.as("ti")
private val t = RTag.as("t")
private val t = RTag.as("t")
private val ro = ROrganization.as("o")
private val rp = RPerson.as("p")
private val re = REquipment.as("e")
private val rc = RContact.as("c")
private val i = RItem.as("i")
private val i = RItem.as("i")
case class Names(org: Vector[String], pers: Vector[String], equip: Vector[String])
object Names {
@ -114,9 +114,9 @@ object QCollective {
for {
incoming <- q0
outgoing <- q1
size <- fileSize
tags <- tagCloud(coll)
deleted <- q2
size <- fileSize
tags <- tagCloud(coll)
deleted <- q2
} yield InsightData(incoming, outgoing, deleted, size.getOrElse(0L), tags)
}
@ -136,10 +136,10 @@ object QCollective {
query: Option[String],
kind: Option[ContactKind]
): Stream[ConnectionIO, RContact] = {
val orgCond = Select(select(ro.oid), from(ro), ro.cid === coll)
val persCond = Select(select(rp.pid), from(rp), rp.cid === coll)
val orgCond = Select(select(ro.oid), from(ro), ro.cid === coll)
val persCond = Select(select(rp.pid), from(rp), rp.cid === coll)
val valueFilter = query.map(s => rc.value.like(s"%${s.toLowerCase}%"))
val kindFilter = kind.map(k => rc.kind === k)
val kindFilter = kind.map(k => rc.kind === k)
Select(
select(rc.all),

View File

@ -64,7 +64,7 @@ object QFolder {
} yield FolderChangeResult.success
(for {
uid <- OptionT(findUserId(account))
uid <- OptionT(findUserId(account))
folder <- OptionT(RFolder.findById(id))
res <- OptionT.liftF(
if (folder.owner == uid) tryDelete
@ -87,7 +87,7 @@ object QFolder {
} yield res
(for {
uid <- OptionT(findUserId(account))
uid <- OptionT(findUserId(account))
folder <- OptionT(RFolder.findById(folder))
res <- OptionT.liftF(
if (folder.owner == uid) tryUpdate(folder.copy(name = name))
@ -110,7 +110,7 @@ object QFolder {
} yield res
(for {
uid <- OptionT(findUserId(account))
uid <- OptionT(findUserId(account))
folder <- OptionT(RFolder.findById(folder))
res <- OptionT.liftF(
if (folder.owner == uid) tryRemove
@ -134,7 +134,7 @@ object QFolder {
} yield res
(for {
uid <- OptionT(findUserId(account))
uid <- OptionT(findUserId(account))
folder <- OptionT(RFolder.findById(folder))
res <- OptionT.liftF(
if (folder.owner == uid) tryAdd
@ -144,7 +144,7 @@ object QFolder {
}
def findById(id: Ident, account: AccountId): ConnectionIO[Option[FolderDetail]] = {
val user = RUser.as("u")
val user = RUser.as("u")
val member = RFolderMember.as("m")
val folder = RFolder.as("s")
@ -194,12 +194,12 @@ object QFolder {
// inner join user_ u on u.uid = s.owner
// where s.cid = 'eike';
val user = RUser.as("u")
val member = RFolderMember.as("m")
val folder = RFolder.as("s")
val user = RUser.as("u")
val member = RFolderMember.as("m")
val folder = RFolder.as("s")
val memlogin = TableDef("memberlogin")
val mlFolder = Column[Ident]("folder", memlogin)
val mlLogin = Column[Ident]("login", memlogin)
val mlLogin = Column[Ident]("login", memlogin)
withCte(
memlogin -> union(
@ -251,8 +251,8 @@ object QFolder {
/** Select all folder_id where the given account is member or owner. */
def findMemberFolderIds(account: AccountId): Select = {
val user = RUser.as("u")
val f = RFolder.as("f")
val m = RFolderMember.as("m")
val f = RFolder.as("f")
val m = RFolderMember.as("m")
union(
Select(
select(f.id),

View File

@ -31,17 +31,17 @@ object QItem {
private[this] val logger = getLogger
private val equip = REquipment.as("e")
private val org = ROrganization.as("o")
private val org = ROrganization.as("o")
private val pers0 = RPerson.as("pers0")
private val pers1 = RPerson.as("pers1")
private val f = RFolder.as("f")
private val i = RItem.as("i")
private val cf = RCustomField.as("cf")
private val cv = RCustomFieldValue.as("cvf")
private val a = RAttachment.as("a")
private val m = RAttachmentMeta.as("m")
private val tag = RTag.as("t")
private val ti = RTagItem.as("ti")
private val f = RFolder.as("f")
private val i = RItem.as("i")
private val cf = RCustomField.as("cf")
private val cv = RCustomFieldValue.as("cvf")
private val a = RAttachment.as("a")
private val m = RAttachmentMeta.as("m")
private val tag = RTag.as("t")
private val ti = RTagItem.as("ti")
def countAttachmentsAndItems(items: Nel[Ident]): ConnectionIO[Int] =
Select(count(a.id).s, from(a), a.itemId.in(items)).build
@ -82,19 +82,19 @@ object QItem {
]
.option
logger.trace(s"Find item query: $cq")
val attachs = RAttachment.findByItemWithMeta(id)
val sources = RAttachmentSource.findByItemWithMeta(id)
val archives = RAttachmentArchive.findByItemWithMeta(id)
val tags = RTag.findByItem(id)
val attachs = RAttachment.findByItemWithMeta(id)
val sources = RAttachmentSource.findByItemWithMeta(id)
val archives = RAttachmentArchive.findByItemWithMeta(id)
val tags = RTag.findByItem(id)
val customfields = findCustomFieldValuesForItem(id)
for {
data <- q
att <- attachs
att <- attachs
srcs <- sources
arch <- archives
ts <- tags
cfs <- customfields
ts <- tags
cfs <- customfields
} yield data.map(d =>
ItemData(d._1, d._2, d._3, d._4, d._5, d._6, d._7, ts, att, srcs, arch, cfs)
)
@ -187,10 +187,10 @@ object QItem {
def searchStats(today: LocalDate)(q: Query): ConnectionIO[SearchSummary] =
for {
count <- searchCountSummary(today)(q)
tags <- searchTagSummary(today)(q)
cats <- searchTagCategorySummary(today)(q)
fields <- searchFieldSummary(today)(q)
count <- searchCountSummary(today)(q)
tags <- searchTagSummary(today)(q)
cats <- searchTagCategorySummary(today)(q)
fields <- searchFieldSummary(today)(q)
folders <- searchFolderSummary(today)(q)
} yield SearchSummary(count, tags, cats, fields, folders)
@ -214,7 +214,7 @@ object QItem {
for {
existing <- catCloud
allCats <- RTag.listCategories(q.fix.account.collective)
allCats <- RTag.listCategories(q.fix.account.collective)
other = allCats.diff(existing.flatMap(_.category))
} yield existing ++ other.map(n => CategoryCount(n.some, 0))
}
@ -239,7 +239,7 @@ object QItem {
// are not included they are fetched separately
for {
existing <- tagCloud
other <- RTag.findOthers(q.fix.account.collective, existing.map(_.tag.tagId))
other <- RTag.findOthers(q.fix.account.collective, existing.map(_.tag.tagId))
} yield existing ++ other.map(TagCount(_, 0))
}
@ -332,10 +332,10 @@ object QItem {
object Tids extends TableDef {
val tableName = "tids"
val alias = Some("tw")
val itemId = Column[Ident]("item_id", this)
val weight = Column[Double]("weight", this)
val all = Vector[Column[_]](itemId, weight)
val alias = Some("tw")
val itemId = Column[Ident]("item_id", this)
val weight = Column[Double]("weight", this)
val all = Vector[Column[_]](itemId, weight)
}
val cte =
@ -389,10 +389,10 @@ object QItem {
for {
resolvedTags <- Stream.eval(Ref.of[ConnectionIO, Map[Ident, RTag]](Map.empty))
item <- search
tagItems <- Stream.eval(RTagItem.findByItem(item.id))
tags <- Stream.eval(tagItems.traverse(ti => findTag(resolvedTags, ti)))
attachs <- Stream.eval(findAttachmentLight(item.id))
item <- search
tagItems <- Stream.eval(RTagItem.findByItem(item.id))
tags <- Stream.eval(tagItems.traverse(ti => findTag(resolvedTags, ti)))
attachs <- Stream.eval(findAttachmentLight(item.id))
ftags = tags.flatten.filter(t => t.collective == collective)
cfields <- Stream.eval(findCustomFieldValuesForItem(item.id))
} yield ListItemWithTags(
@ -418,7 +418,7 @@ object QItem {
mn <- store.transact(RSentMail.deleteByItem(itemId))
cf <- store.transact(RCustomFieldValue.deleteByItem(itemId))
im <- store.transact(RItemProposal.deleteByItem(itemId))
n <- store.transact(RItem.deleteByIdAndCollective(itemId, collective))
n <- store.transact(RItem.deleteByIdAndCollective(itemId, collective))
} yield tn + rn + n + mn + cf + im
private def findByFileIdsQuery(
@ -476,13 +476,13 @@ object QItem {
collective: Ident,
excludeFileMeta: Set[Ident]
): Select = {
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 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)
Select(
select(i.all),
@ -551,9 +551,9 @@ object QItem {
maxLen: Int,
pageSep: String
): ConnectionIO[TextAndTag] = {
val tags = TableDef("tags").as("tt")
val tags = TableDef("tags").as("tt")
val tagsItem = Column[Ident]("itemid", tags)
val tagsTid = Column[Ident]("tid", tags)
val tagsTid = Column[Ident]("tid", tags)
val tagsName = Column[String]("tname", tags)
readTextAndTag(collective, itemId, pageSep) {

View File

@ -77,16 +77,16 @@ object QJob {
_ <- logger.ftrace[F](
s"About to take next job (worker ${worker.id}), try $currentTry"
)
now <- Timestamp.current[F]
now <- Timestamp.current[F]
group <- store.transact(selectNextGroup(worker, now, retryPause))
_ <- logger.ftrace[F](s"Choose group ${group.map(_.id)}")
prio <- group.map(priority).getOrElse((Priority.Low: Priority).pure[F])
_ <- logger.ftrace[F](s"Looking for job of prio $prio")
_ <- logger.ftrace[F](s"Choose group ${group.map(_.id)}")
prio <- group.map(priority).getOrElse((Priority.Low: Priority).pure[F])
_ <- logger.ftrace[F](s"Looking for job of prio $prio")
job <-
group
.map(g => store.transact(selectNextJob(g, prio, retryPause, now)))
.getOrElse((None: Option[RJob]).pure[F])
_ <- logger.ftrace[F](s"Found job: ${job.map(_.info)}")
_ <- logger.ftrace[F](s"Found job: ${job.map(_.info)}")
res <- job.traverse(j => markJob(j))
} yield res.map(_.map(_.some)).getOrElse {
if (group.isDefined)
@ -101,7 +101,7 @@ object QJob {
initialPause: Duration
): ConnectionIO[Option[Ident]] = {
val JC = RJob.as("a")
val G = RJobGroupUse.as("b")
val G = RJobGroupUse.as("b")
val stuckTrigger = stuckTriggerValue(JC, initialPause, now)
val stateCond =
@ -109,7 +109,7 @@ object QJob {
object AllGroups extends TableDef {
val tableName = "allgroups"
val alias = Some("ag")
val alias = Some("ag")
val group: Column[Ident] = JC.group.copy(table = this)
@ -162,7 +162,7 @@ object QJob {
if (prio == Priority.High) JC.priority.desc
else JC.priority.asc
val waiting = JobState.waiting
val stuck = JobState.stuck
val stuck = JobState.stuck
val stuckTrigger = stuckTriggerValue(JC, initialPause, now)
val sql =
@ -179,31 +179,31 @@ object QJob {
def setCancelled[F[_]: Async](id: Ident, store: Store[F]): F[Unit] =
for {
now <- Timestamp.current[F]
_ <- store.transact(RJob.setCancelled(id, now))
_ <- store.transact(RJob.setCancelled(id, now))
} yield ()
def setFailed[F[_]: Async](id: Ident, store: Store[F]): F[Unit] =
for {
now <- Timestamp.current[F]
_ <- store.transact(RJob.setFailed(id, now))
_ <- store.transact(RJob.setFailed(id, now))
} yield ()
def setSuccess[F[_]: Async](id: Ident, store: Store[F]): F[Unit] =
for {
now <- Timestamp.current[F]
_ <- store.transact(RJob.setSuccess(id, now))
_ <- store.transact(RJob.setSuccess(id, now))
} yield ()
def setStuck[F[_]: Async](id: Ident, store: Store[F]): F[Unit] =
for {
now <- Timestamp.current[F]
_ <- store.transact(RJob.setStuck(id, now))
_ <- store.transact(RJob.setStuck(id, now))
} yield ()
def setRunning[F[_]: Async](id: Ident, workerId: Ident, store: Store[F]): F[Unit] =
for {
now <- Timestamp.current[F]
_ <- store.transact(RJob.setRunning(id, workerId, now))
_ <- store.transact(RJob.setRunning(id, workerId, now))
} yield ()
def setFinalState[F[_]: Async](id: Ident, state: JobState, store: Store[F]): F[Unit] =
@ -233,7 +233,7 @@ object QJob {
collective: Ident,
max: Long
): Stream[ConnectionIO, (RJob, Vector[RJobLog])] = {
val JC = RJob.T
val JC = RJob.T
val waiting = NonEmptyList.of(JobState.Waiting, JobState.Stuck, JobState.Scheduled)
val running = NonEmptyList.of(JobState.Running)
//val done = JobState.all.filterNot(js => ).diff(waiting).diff(running)

View File

@ -18,10 +18,10 @@ import doobie.implicits._
object QMails {
private val item = RItem.as("i")
private val smail = RSentMail.as("sm")
private val item = RItem.as("i")
private val smail = RSentMail.as("sm")
private val mailitem = RSentMailItem.as("mi")
private val user = RUser.as("u")
private val user = RUser.as("u")
def delete(coll: Ident, mailId: Ident): ConnectionIO[Int] =
(for {

View File

@ -20,8 +20,8 @@ import doobie._
import doobie.implicits._
object QOrganization {
private val p = RPerson.as("p")
private val c = RContact.as("c")
private val p = RPerson.as("p")
private val c = RContact.as("c")
private val org = ROrganization.as("o")
def findOrgAndContact(
@ -144,7 +144,7 @@ object QOrganization {
cid: Ident
): Store[F] => F[AddResult] = {
val insert = for {
n <- ROrganization.insert(org)
n <- ROrganization.insert(org)
cs <- contacts.toList.traverse(RContact.insert)
} yield n + cs.sum
@ -159,7 +159,7 @@ object QOrganization {
cid: Ident
): Store[F] => F[AddResult] = {
val insert = for {
n <- RPerson.insert(person)
n <- RPerson.insert(person)
cs <- contacts.toList.traverse(RContact.insert)
} yield n + cs.sum
@ -174,8 +174,8 @@ object QOrganization {
cid: Ident
): Store[F] => F[AddResult] = {
val insert = for {
n <- ROrganization.update(org)
d <- RContact.deleteOrg(org.oid)
n <- ROrganization.update(org)
d <- RContact.deleteOrg(org.oid)
cs <- contacts.toList.traverse(RContact.insert)
} yield n + cs.sum + d
@ -190,8 +190,8 @@ object QOrganization {
cid: Ident
): Store[F] => F[AddResult] = {
val insert = for {
n <- RPerson.update(person)
d <- RContact.deletePerson(person.pid)
n <- RPerson.update(person)
d <- RContact.deletePerson(person.pid)
cs <- contacts.toList.traverse(RContact.insert)
} yield n + cs.sum + d

View File

@ -25,9 +25,9 @@ object QUser {
def getUserData(accountId: AccountId): ConnectionIO[UserData] = {
val folder = RFolder.as("f")
val mail = RSentMail.as("m")
val mitem = RSentMailItem.as("mi")
val user = RUser.as("u")
val mail = RSentMail.as("m")
val mitem = RSentMailItem.as("mi")
val user = RUser.as("u")
for {
uid <- loadUserId(accountId).map(_.getOrElse(Ident.unsafe("")))
@ -49,21 +49,21 @@ object QUser {
def deleteUserAndData(accountId: AccountId): ConnectionIO[Int] =
for {
uid <- loadUserId(accountId).map(_.getOrElse(Ident.unsafe("")))
_ <- logger.info(s"Remove user ${accountId.asString} (uid=${uid.id})")
_ <- logger.info(s"Remove user ${accountId.asString} (uid=${uid.id})")
n1 <- deleteUserFolders(uid)
n2 <- deleteUserSentMails(uid)
_ <- logger.info(s"Removed $n2 sent mails")
_ <- logger.info(s"Removed $n2 sent mails")
n3 <- deleteRememberMe(accountId)
_ <- logger.info(s"Removed $n3 remember me tokens")
_ <- logger.info(s"Removed $n3 remember me tokens")
n4 <- deleteTotp(uid)
_ <- logger.info(s"Removed $n4 totp secrets")
_ <- logger.info(s"Removed $n4 totp secrets")
n5 <- deleteMailSettings(uid)
_ <- logger.info(s"Removed $n5 mail settings")
_ <- logger.info(s"Removed $n5 mail settings")
nu <- RUser.deleteById(uid)
} yield nu + n1 + n2 + n3 + n4 + n5
@ -80,16 +80,16 @@ object QUser {
_ <- logger.info(s"Removing folders: ${folders.map(_.id)}")
ri <- folders.traverse(RItem.removeFolder)
_ <- logger.info(s"Removed folders from items: $ri")
_ <- logger.info(s"Removed folders from items: $ri")
rs <- folders.traverse(RSource.removeFolder)
_ <- logger.info(s"Removed folders from sources: $rs")
_ <- logger.info(s"Removed folders from sources: $rs")
rf <- folders.traverse(RFolderMember.deleteAll)
_ <- logger.info(s"Removed folders from members: $rf")
_ <- logger.info(s"Removed folders from members: $rf")
n1 <- DML.delete(member, member.user === uid)
_ <- logger.info(s"Removed $n1 members for owning folders.")
_ <- logger.info(s"Removed $n1 members for owning folders.")
n2 <- DML.delete(folder, folder.owner === uid)
_ <- logger.info(s"Removed $n2 folders.")
_ <- logger.info(s"Removed $n2 folders.")
} yield n1 + n2 + ri.sum + rs.sum + rf.sum
}
@ -98,8 +98,8 @@ object QUser {
val mail = RSentMail.as("m")
for {
ids <- run(select(mail.id), from(mail), mail.uid === uid).query[Ident].to[List]
n1 <- ids.traverse(RSentMailItem.deleteMail)
n2 <- ids.traverse(RSentMail.delete)
n1 <- ids.traverse(RSentMailItem.deleteMail)
n2 <- ids.traverse(RSentMail.delete)
} yield n1.sum + n2.sum
}

View File

@ -17,6 +17,6 @@ object Marked {
final case object NotMarkable extends Marked[Nothing]
def found[A](v: A): Marked[A] = Found(v)
def notFound[A]: Marked[A] = NotFound
def notFound[A]: Marked[A] = NotFound
def notMarkable[A]: Marked[A] = NotMarkable
}

View File

@ -33,16 +33,13 @@ trait PeriodicTaskStore[F[_]] {
def findNonFinalJob(pjobId: Ident): F[Option[RJob]]
/** Insert a task or update if it already exists.
*/
/** Insert a task or update if it already exists. */
def insert(task: RPeriodicTask): F[Unit]
/** Adds the task only if it not already exists.
*/
/** Adds the task only if it not already exists. */
def add(task: RPeriodicTask): F[AddResult]
/** Find all joex nodes as registered in the database.
*/
/** Find all joex nodes as registered in the database. */
def findJoexNodes: F[Vector[RNode]]
}
@ -109,9 +106,9 @@ object PeriodicTaskStore {
}
for {
n1 <- update
n1 <- update
ins <- if (n1 == 0) insertAttempt else true.pure[F]
_ <- if (ins) 1.pure[F] else update
_ <- if (ins) 1.pure[F] else update
} yield ()
}

View File

@ -30,13 +30,13 @@ object RAttachment {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "attachment"
val id = Column[Ident]("attachid", this)
val itemId = Column[Ident]("itemid", this)
val fileId = Column[Ident]("filemetaid", this)
val id = Column[Ident]("attachid", this)
val itemId = Column[Ident]("itemid", this)
val fileId = Column[Ident]("filemetaid", this)
val position = Column[Int]("position", this)
val created = Column[Timestamp]("created", this)
val name = Column[String]("name", this)
val all = NonEmptyList.of[Column[_]](id, itemId, fileId, position, created, name)
val created = Column[Timestamp]("created", this)
val name = Column[String]("name", this)
val all = NonEmptyList.of[Column[_]](id, itemId, fileId, position, created, name)
}
val T = Table(None)
@ -131,7 +131,7 @@ object RAttachment {
val update = DML.update(T, T.id === attachId, DML.set(T.name.setTo(aname)))
for {
exists <- existsByIdAndCollective(attachId, collective)
n <- if (exists) update else 0.pure[ConnectionIO]
n <- if (exists) update else 0.pure[ConnectionIO]
} yield n
}
@ -227,8 +227,7 @@ object RAttachment {
).orderBy(a.position.asc).build.query[(RAttachment, RFileMeta)].to[Vector]
}
/** Deletes the attachment and its related source and meta records.
*/
/** Deletes the attachment and its related source and meta records. */
def delete(attachId: Ident): ConnectionIO[Int] =
for {
n0 <- RAttachmentMeta.delete(attachId)
@ -294,10 +293,10 @@ object RAttachment {
chunkSize: Int
): Stream[ConnectionIO, RAttachment] = {
val pdfType = "application/pdf%"
val a = RAttachment.as("a")
val s = RAttachmentSource.as("s")
val i = RItem.as("i")
val m = RFileMeta.as("m")
val a = RAttachment.as("a")
val s = RAttachmentSource.as("s")
val i = RItem.as("i")
val m = RFileMeta.as("m")
Select(
select(a.all),

View File

@ -31,11 +31,11 @@ object RAttachmentArchive {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "attachment_archive"
val id = Column[Ident]("id", this)
val fileId = Column[Ident]("file_id", this)
val name = Column[String]("filename", this)
val id = Column[Ident]("id", this)
val fileId = Column[Ident]("file_id", this)
val name = Column[String]("filename", this)
val messageId = Column[String]("message_id", this)
val created = Column[Timestamp]("created", this)
val created = Column[Timestamp]("created", this)
val all = NonEmptyList.of[Column[_]](id, fileId, name, messageId, created)
}

View File

@ -40,12 +40,12 @@ object RAttachmentMeta {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "attachmentmeta"
val id = Column[Ident]("attachid", this)
val content = Column[String]("content", this)
val id = Column[Ident]("attachid", this)
val content = Column[String]("content", this)
val nerlabels = Column[List[NerLabel]]("nerlabels", this)
val proposals = Column[MetaProposalList]("itemproposals", this)
val pages = Column[Int]("page_count", this)
val language = Column[Language]("language", this)
val pages = Column[Int]("page_count", this)
val language = Column[Language]("language", this)
val all =
NonEmptyList.of[Column[_]](
id,

View File

@ -29,9 +29,9 @@ object RAttachmentPreview {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "attachment_preview"
val id = Column[Ident]("id", this)
val fileId = Column[Ident]("file_id", this)
val name = Column[String]("filename", this)
val id = Column[Ident]("id", this)
val fileId = Column[Ident]("file_id", this)
val name = Column[String]("filename", this)
val created = Column[Timestamp]("created", this)
val all = NonEmptyList.of[Column[_]](id, fileId, name, created)

View File

@ -29,9 +29,9 @@ object RAttachmentSource {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "attachment_source"
val id = Column[Ident]("id", this)
val fileId = Column[Ident]("file_id", this)
val name = Column[String]("filename", this)
val id = Column[Ident]("id", this)
val fileId = Column[Ident]("file_id", this)
val name = Column[String]("filename", this)
val created = Column[Timestamp]("created", this)
val all = NonEmptyList.of[Column[_]](id, fileId, name, created)

View File

@ -33,17 +33,17 @@ object RClassifierModel {
fileId: Ident
): F[RClassifierModel] =
for {
id <- Ident.randomId[F]
id <- Ident.randomId[F]
now <- Timestamp.current[F]
} yield RClassifierModel(id, cid, name, fileId, now)
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "classifier_model"
val id = Column[Ident]("id", this)
val cid = Column[Ident]("cid", this)
val name = Column[String]("name", this)
val fileId = Column[Ident]("file_id", this)
val id = Column[Ident]("id", this)
val cid = Column[Ident]("cid", this)
val name = Column[String]("name", this)
val fileId = Column[Ident]("file_id", this)
val created = Column[Timestamp]("created", this)
val all = NonEmptyList.of[Column[_]](id, cid, name, fileId, created)

View File

@ -43,12 +43,12 @@ object RClassifierSetting {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "classifier_setting"
val cid = Column[Ident]("cid", this)
val schedule = Column[CalEvent]("schedule", this)
val itemCount = Column[Int]("item_count", this)
val created = Column[Timestamp]("created", this)
val cid = Column[Ident]("cid", this)
val schedule = Column[CalEvent]("schedule", this)
val itemCount = Column[Int]("item_count", this)
val created = Column[Timestamp]("created", this)
val categories = Column[List[String]]("categories", this)
val listType = Column[ListType]("category_list_type", this)
val listType = Column[ListType]("category_list_type", this)
val all = NonEmptyList
.of[Column[_]](cid, schedule, itemCount, created, categories, listType)
}

View File

@ -31,18 +31,18 @@ object RClientSettings {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "client_settings"
val id = Column[Ident]("id", this)
val clientId = Column[Ident]("client_id", this)
val userId = Column[Ident]("user_id", this)
val id = Column[Ident]("id", this)
val clientId = Column[Ident]("client_id", this)
val userId = Column[Ident]("user_id", this)
val settingsData = Column[Json]("settings_data", this)
val updated = Column[Timestamp]("updated", this)
val created = Column[Timestamp]("created", this)
val updated = Column[Timestamp]("updated", this)
val created = Column[Timestamp]("created", this)
val all =
NonEmptyList.of[Column[_]](id, clientId, userId, settingsData, updated, created)
}
def as(alias: String): Table = Table(Some(alias))
val T = Table(None)
val T = Table(None)
def insert(v: RClientSettings): ConnectionIO[Int] = {
val t = Table(None)
@ -67,7 +67,7 @@ object RClientSettings {
def upsert(clientId: Ident, userId: Ident, data: Json): ConnectionIO[Int] =
for {
id <- Ident.randomId[ConnectionIO]
id <- Ident.randomId[ConnectionIO]
now <- Timestamp.current[ConnectionIO]
nup <- updateSettings(clientId, userId, data, now)
nin <-

View File

@ -28,11 +28,11 @@ object RCollective {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "collective"
val id = Column[Ident]("cid", this)
val state = Column[CollectiveState]("state", this)
val language = Column[Language]("doclang", this)
val id = Column[Ident]("cid", this)
val state = Column[CollectiveState]("state", this)
val language = Column[Language]("doclang", this)
val integration = Column[Boolean]("integration_enabled", this)
val created = Column[Timestamp]("created", this)
val created = Column[Timestamp]("created", this)
val all = NonEmptyList.of[Column[_]](id, state, language, integration, created)
}
@ -103,7 +103,7 @@ object RCollective {
private def getRawSettings(coll: Ident): ConnectionIO[Option[Settings]] = {
import RClassifierSetting.stringListMeta
val c = RCollective.as("c")
val c = RCollective.as("c")
val cs = RClassifierSetting.as("cs")
val es = REmptyTrashSetting.as("es")

View File

@ -30,11 +30,11 @@ object RContact {
val tableName = "contact"
val contactId = Column[Ident]("contactid", this)
val value = Column[String]("value", this)
val kind = Column[ContactKind]("kind", this)
val personId = Column[Ident]("pid", this)
val orgId = Column[Ident]("oid", this)
val created = Column[Timestamp]("created", this)
val value = Column[String]("value", this)
val kind = Column[ContactKind]("kind", this)
val personId = Column[Ident]("pid", this)
val orgId = Column[Ident]("oid", this)
val created = Column[Timestamp]("created", this)
val all = NonEmptyList.of[Column[_]](contactId, value, kind, personId, orgId, created)
}

View File

@ -29,11 +29,11 @@ object RCustomField {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "custom_field"
val id = Column[Ident]("id", this)
val name = Column[Ident]("name", this)
val label = Column[String]("label", this)
val cid = Column[Ident]("cid", this)
val ftype = Column[CustomFieldType]("ftype", this)
val id = Column[Ident]("id", this)
val name = Column[Ident]("name", this)
val label = Column[String]("label", this)
val cid = Column[Ident]("cid", this)
val ftype = Column[CustomFieldType]("ftype", this)
val created = Column[Timestamp]("created", this)
val all = NonEmptyList.of[Column[_]](id, name, label, cid, ftype, created)

View File

@ -26,10 +26,10 @@ object RCustomFieldValue {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "custom_field_value"
val id = Column[Ident]("id", this)
val id = Column[Ident]("id", this)
val itemId = Column[Ident]("item_id", this)
val field = Column[Ident]("field", this)
val value = Column[String]("field_value", this)
val field = Column[Ident]("field", this)
val value = Column[String]("field_value", this)
val all = NonEmptyList.of[Column[_]](id, itemId, field, value)
}

View File

@ -30,11 +30,11 @@ object REmptyTrashSetting {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "empty_trash_setting"
val cid = Column[Ident]("cid", this)
val cid = Column[Ident]("cid", this)
val schedule = Column[CalEvent]("schedule", this)
val minAge = Column[Duration]("min_age", this)
val created = Column[Timestamp]("created", this)
val all = NonEmptyList.of[Column[_]](cid, schedule, minAge, created)
val minAge = Column[Duration]("min_age", this)
val created = Column[Timestamp]("created", this)
val all = NonEmptyList.of[Column[_]](cid, schedule, minAge, created)
}
val T = Table(None)

View File

@ -29,14 +29,14 @@ object REquipment {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "equipment"
val eid = Column[Ident]("eid", this)
val cid = Column[Ident]("cid", this)
val name = Column[String]("name", this)
val eid = Column[Ident]("eid", this)
val cid = Column[Ident]("cid", this)
val name = Column[String]("name", this)
val created = Column[Timestamp]("created", this)
val updated = Column[Timestamp]("updated", this)
val notes = Column[String]("notes", this)
val use = Column[EquipmentUse]("equip_use", this)
val all = NonEmptyList.of[Column[_]](eid, cid, name, created, updated, notes, use)
val notes = Column[String]("notes", this)
val use = Column[EquipmentUse]("equip_use", this)
val all = NonEmptyList.of[Column[_]](eid, cid, name, created, updated, notes, use)
}
val T = Table(None)
@ -73,13 +73,13 @@ object REquipment {
}
def existsByName(coll: Ident, ename: String): ConnectionIO[Boolean] = {
val t = Table(None)
val t = Table(None)
val sql = run(select(count(t.eid)), from(t), where(t.cid === coll, t.name === ename))
sql.query[Int].unique.map(_ > 0)
}
def findById(id: Ident): ConnectionIO[Option[REquipment]] = {
val t = Table(None)
val t = Table(None)
val sql = run(select(t.all), from(t), t.eid === id)
sql.query[REquipment].option
}

View File

@ -29,11 +29,11 @@ object RFileMeta {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "filemeta"
val id = Column[Ident]("file_id", this)
val id = Column[Ident]("file_id", this)
val timestamp = Column[Timestamp]("created", this)
val mimetype = Column[MimeType]("mimetype", this)
val length = Column[ByteSize]("length", this)
val checksum = Column[ByteVector]("checksum", this)
val mimetype = Column[MimeType]("mimetype", this)
val length = Column[ByteSize]("length", this)
val checksum = Column[ByteVector]("checksum", this)
val all = NonEmptyList
.of[Column[_]](id, timestamp, mimetype, length, checksum)

View File

@ -36,11 +36,11 @@ object RFolder {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "folder"
val id = Column[Ident]("id", this)
val name = Column[String]("name", this)
val id = Column[Ident]("id", this)
val name = Column[String]("name", this)
val collective = Column[Ident]("cid", this)
val owner = Column[Ident]("owner", this)
val created = Column[Timestamp]("created", this)
val owner = Column[Ident]("owner", this)
val created = Column[Timestamp]("created", this)
val all = NonEmptyList.of[Column[_]](id, name, collective, owner, created)
}

View File

@ -35,9 +35,9 @@ object RFolderMember {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "folder_member"
val id = Column[Ident]("id", this)
val folder = Column[Ident]("folder_id", this)
val user = Column[Ident]("user_id", this)
val id = Column[Ident]("id", this)
val folder = Column[Ident]("folder_id", this)
val user = Column[Ident]("user_id", this)
val created = Column[Timestamp]("created", this)
val all = NonEmptyList.of[Column[_]](id, folder, user, created)

View File

@ -23,9 +23,9 @@ object RInvitation {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "invitation"
val id = Column[Ident]("id", this)
val id = Column[Ident]("id", this)
val created = Column[Timestamp]("created", this)
val all = NonEmptyList.of[Column[_]](id, created)
val all = NonEmptyList.of[Column[_]](id, created)
}
val T = Table(None)
@ -56,7 +56,7 @@ object RInvitation {
.unique
for {
inv <- get
_ <- delete(invite)
_ <- delete(invite)
} yield inv > 0
}

View File

@ -49,7 +49,7 @@ object RItem {
): F[RItem] =
for {
now <- Timestamp.current[F]
id <- Ident.randomId[F]
id <- Ident.randomId[F]
} yield RItem(
id,
cid,
@ -74,23 +74,23 @@ object RItem {
import docspell.store.qb.Column
val tableName = "item"
val id = Column[Ident]("itemid", this)
val cid = Column[Ident]("cid", this)
val name = Column[String]("name", this)
val itemDate = Column[Timestamp]("itemdate", this)
val source = Column[String]("source", this)
val incoming = Column[Direction]("incoming", this)
val state = Column[ItemState]("state", this)
val corrOrg = Column[Ident]("corrorg", this)
val corrPerson = Column[Ident]("corrperson", this)
val concPerson = Column[Ident]("concperson", this)
val id = Column[Ident]("itemid", this)
val cid = Column[Ident]("cid", this)
val name = Column[String]("name", this)
val itemDate = Column[Timestamp]("itemdate", this)
val source = Column[String]("source", this)
val incoming = Column[Direction]("incoming", this)
val state = Column[ItemState]("state", this)
val corrOrg = Column[Ident]("corrorg", this)
val corrPerson = Column[Ident]("corrperson", this)
val concPerson = Column[Ident]("concperson", this)
val concEquipment = Column[Ident]("concequipment", this)
val inReplyTo = Column[Ident]("inreplyto", this)
val dueDate = Column[Timestamp]("duedate", this)
val created = Column[Timestamp]("created", this)
val updated = Column[Timestamp]("updated", this)
val notes = Column[String]("notes", this)
val folder = Column[Ident]("folder_id", this)
val inReplyTo = Column[Ident]("inreplyto", this)
val dueDate = Column[Timestamp]("duedate", this)
val created = Column[Timestamp]("created", this)
val updated = Column[Timestamp]("updated", this)
val notes = Column[String]("notes", this)
val folder = Column[Ident]("folder_id", this)
val all = NonEmptyList.of[Column[_]](
id,
cid,

View File

@ -26,10 +26,10 @@ object RItemProposal {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "item_proposal"
val itemId = Column[Ident]("itemid", this)
val itemId = Column[Ident]("itemid", this)
val classifyProposals = Column[MetaProposalList]("classifier_proposals", this)
val classifyTags = Column[List[IdRef]]("classifier_tags", this)
val created = Column[Timestamp]("created", this)
val classifyTags = Column[List[IdRef]]("classifier_tags", this)
val created = Column[Timestamp]("created", this)
val all = NonEmptyList.of[Column[_]](itemId, classifyProposals, classifyTags, created)
}

View File

@ -80,22 +80,22 @@ object RJob {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "job"
val id = Column[Ident]("jid", this)
val task = Column[Ident]("task", this)
val group = Column[Ident]("group_", this)
val args = Column[String]("args", this)
val subject = Column[String]("subject", this)
val submitted = Column[Timestamp]("submitted", this)
val submitter = Column[Ident]("submitter", this)
val priority = Column[Priority]("priority", this)
val state = Column[JobState]("state", this)
val retries = Column[Int]("retries", this)
val progress = Column[Int]("progress", this)
val tracker = Column[Ident]("tracker", this)
val worker = Column[Ident]("worker", this)
val started = Column[Timestamp]("started", this)
val id = Column[Ident]("jid", this)
val task = Column[Ident]("task", this)
val group = Column[Ident]("group_", this)
val args = Column[String]("args", this)
val subject = Column[String]("subject", this)
val submitted = Column[Timestamp]("submitted", this)
val submitter = Column[Ident]("submitter", this)
val priority = Column[Priority]("priority", this)
val state = Column[JobState]("state", this)
val retries = Column[Int]("retries", this)
val progress = Column[Int]("progress", this)
val tracker = Column[Ident]("tracker", this)
val worker = Column[Ident]("worker", this)
val started = Column[Timestamp]("started", this)
val startedmillis = Column[Long]("startedmillis", this)
val finished = Column[Timestamp]("finished", this)
val finished = Column[Timestamp]("finished", this)
val all = NonEmptyList.of[Column[_]](
id,
task,

View File

@ -22,9 +22,9 @@ object RJobGroupUse {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "jobgroupuse"
val group = Column[Ident]("groupid", this)
val group = Column[Ident]("groupid", this)
val worker = Column[Ident]("workerid", this)
val all = NonEmptyList.of[Column[_]](group, worker)
val all = NonEmptyList.of[Column[_]](group, worker)
}
val T = Table(None)

View File

@ -27,12 +27,12 @@ object RJobLog {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "joblog"
val id = Column[Ident]("id", this)
val jobId = Column[Ident]("jid", this)
val level = Column[LogLevel]("level", this)
val id = Column[Ident]("id", this)
val jobId = Column[Ident]("jid", this)
val level = Column[LogLevel]("level", this)
val created = Column[Timestamp]("created", this)
val message = Column[String]("message", this)
val all = NonEmptyList.of[Column[_]](id, jobId, level, created, message)
val all = NonEmptyList.of[Column[_]](id, jobId, level, created, message)
// separate column only for sorting, so not included in `all` and
// the case class

View File

@ -34,11 +34,11 @@ object RNode {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "node"
val id = Column[Ident]("id", this)
val id = Column[Ident]("id", this)
val nodeType = Column[NodeType]("type", this)
val url = Column[LenientUri]("url", this)
val updated = Column[Timestamp]("updated", this)
val created = Column[Timestamp]("created", this)
val url = Column[LenientUri]("url", this)
val updated = Column[Timestamp]("updated", this)
val created = Column[Timestamp]("created", this)
val notFound = Column[Int]("not_found", this)
val all = NonEmptyList.of[Column[_]](id, nodeType, url, updated, created, notFound)
}

View File

@ -39,18 +39,18 @@ object ROrganization {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "organization"
val oid = Column[Ident]("oid", this)
val cid = Column[Ident]("cid", this)
val name = Column[String]("name", this)
val street = Column[String]("street", this)
val zip = Column[String]("zip", this)
val city = Column[String]("city", this)
val country = Column[String]("country", this)
val notes = Column[String]("notes", this)
val created = Column[Timestamp]("created", this)
val updated = Column[Timestamp]("updated", this)
val oid = Column[Ident]("oid", this)
val cid = Column[Ident]("cid", this)
val name = Column[String]("name", this)
val street = Column[String]("street", this)
val zip = Column[String]("zip", this)
val city = Column[String]("city", this)
val country = Column[String]("country", this)
val notes = Column[String]("notes", this)
val created = Column[Timestamp]("created", this)
val updated = Column[Timestamp]("updated", this)
val shortName = Column[String]("short_name", this)
val use = Column[OrgUse]("org_use", this)
val use = Column[OrgUse]("org_use", this)
val all =
Nel.of[Column[_]](
oid,
@ -99,7 +99,7 @@ object ROrganization {
)
for {
now <- Timestamp.current[ConnectionIO]
n <- sql(now)
n <- sql(now)
} yield n
}

View File

@ -128,20 +128,20 @@ object RPeriodicTask {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "periodic_task"
val id = Column[Ident]("id", this)
val enabled = Column[Boolean]("enabled", this)
val task = Column[Ident]("task", this)
val group = Column[Ident]("group_", this)
val args = Column[String]("args", this)
val subject = Column[String]("subject", this)
val id = Column[Ident]("id", this)
val enabled = Column[Boolean]("enabled", this)
val task = Column[Ident]("task", this)
val group = Column[Ident]("group_", this)
val args = Column[String]("args", this)
val subject = Column[String]("subject", this)
val submitter = Column[Ident]("submitter", this)
val priority = Column[Priority]("priority", this)
val worker = Column[Ident]("worker", this)
val marked = Column[Timestamp]("marked", this)
val timer = Column[CalEvent]("timer", this)
val nextrun = Column[Timestamp]("nextrun", this)
val created = Column[Timestamp]("created", this)
val summary = Column[String]("summary", this)
val priority = Column[Priority]("priority", this)
val worker = Column[Ident]("worker", this)
val marked = Column[Timestamp]("marked", this)
val timer = Column[CalEvent]("timer", this)
val nextrun = Column[Timestamp]("nextrun", this)
val created = Column[Timestamp]("created", this)
val summary = Column[String]("summary", this)
val all = NonEmptyList.of[Column[_]](
id,
enabled,

View File

@ -40,18 +40,18 @@ object RPerson {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "person"
val pid = Column[Ident]("pid", this)
val cid = Column[Ident]("cid", this)
val name = Column[String]("name", this)
val street = Column[String]("street", this)
val zip = Column[String]("zip", this)
val city = Column[String]("city", this)
val pid = Column[Ident]("pid", this)
val cid = Column[Ident]("cid", this)
val name = Column[String]("name", this)
val street = Column[String]("street", this)
val zip = Column[String]("zip", this)
val city = Column[String]("city", this)
val country = Column[String]("country", this)
val notes = Column[String]("notes", this)
val notes = Column[String]("notes", this)
val created = Column[Timestamp]("created", this)
val updated = Column[Timestamp]("updated", this)
val oid = Column[Ident]("oid", this)
val use = Column[PersonUse]("person_use", this)
val oid = Column[Ident]("oid", this)
val use = Column[PersonUse]("person_use", this)
val all = Nel.of[Column[_]](
pid,
cid,
@ -99,7 +99,7 @@ object RPerson {
)
for {
now <- Timestamp.current[ConnectionIO]
n <- sql(now)
n <- sql(now)
} yield n
}

View File

@ -23,12 +23,12 @@ object RRememberMe {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "rememberme"
val id = Column[Ident]("id", this)
val cid = Column[Ident]("cid", this)
val id = Column[Ident]("id", this)
val cid = Column[Ident]("cid", this)
val username = Column[Ident]("login", this)
val created = Column[Timestamp]("created", this)
val uses = Column[Int]("uses", this)
val all = NonEmptyList.of[Column[_]](id, cid, username, created, uses)
val created = Column[Timestamp]("created", this)
val uses = Column[Int]("uses", this)
val all = NonEmptyList.of[Column[_]](id, cid, username, created, uses)
}
val T = Table(None)
@ -69,7 +69,7 @@ object RRememberMe {
.option
for {
inv <- get
_ <- incrementUse(rid)
_ <- incrementUse(rid)
} yield inv
}

View File

@ -44,7 +44,7 @@ object RSentMail {
body: String
): F[RSentMail] =
for {
id <- Ident.randomId[F]
id <- Ident.randomId[F]
now <- Timestamp.current[F]
} yield RSentMail(
id,
@ -88,15 +88,15 @@ object RSentMail {
val tableName = "sentmail"
val id = Column[Ident]("id", this)
val uid = Column[Ident]("uid", this)
val messageId = Column[String]("message_id", this)
val sender = Column[MailAddress]("sender", this)
val connName = Column[Ident]("conn_name", this)
val subject = Column[String]("subject", this)
val id = Column[Ident]("id", this)
val uid = Column[Ident]("uid", this)
val messageId = Column[String]("message_id", this)
val sender = Column[MailAddress]("sender", this)
val connName = Column[Ident]("conn_name", this)
val subject = Column[String]("subject", this)
val recipients = Column[List[MailAddress]]("recipients", this)
val body = Column[String]("body", this)
val created = Column[Timestamp]("created", this)
val body = Column[String]("body", this)
val created = Column[Timestamp]("created", this)
val all = NonEmptyList.of[Column[_]](
id,
@ -131,7 +131,7 @@ object RSentMail {
def deleteByItem(item: Ident): ConnectionIO[Int] =
for {
list <- RSentMailItem.findSentMailIdsByItem(item)
n1 <- RSentMailItem.deleteAllByItem(item)
n1 <- RSentMailItem.deleteAllByItem(item)
n0 <- NonEmptyList.fromList(list.toList) match {
case Some(nel) => DML.delete(T, T.id.in(nel))
case None => 0.pure[ConnectionIO]

View File

@ -32,17 +32,17 @@ object RSentMailItem {
created: Option[Timestamp] = None
): F[RSentMailItem] =
for {
id <- Ident.randomId[F]
id <- Ident.randomId[F]
now <- created.map(_.pure[F]).getOrElse(Timestamp.current[F])
} yield RSentMailItem(id, itemId, sentmailId, now)
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "sentmailitem"
val id = Column[Ident]("id", this)
val itemId = Column[Ident]("item_id", this)
val id = Column[Ident]("id", this)
val itemId = Column[Ident]("item_id", this)
val sentMailId = Column[Ident]("sentmail_id", this)
val created = Column[Timestamp]("created", this)
val created = Column[Timestamp]("created", this)
val all = NonEmptyList.of[Column[_]](
id,

View File

@ -39,18 +39,18 @@ object RSource {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "source"
val sid = Column[Ident]("sid", this)
val cid = Column[Ident]("cid", this)
val abbrev = Column[String]("abbrev", this)
val sid = Column[Ident]("sid", this)
val cid = Column[Ident]("cid", this)
val abbrev = Column[String]("abbrev", this)
val description = Column[String]("description", this)
val counter = Column[Int]("counter", this)
val enabled = Column[Boolean]("enabled", this)
val priority = Column[Priority]("priority", this)
val created = Column[Timestamp]("created", this)
val folder = Column[Ident]("folder_id", this)
val fileFilter = Column[Glob]("file_filter", this)
val language = Column[Language]("doc_lang", this)
val attachOnly = Column[Boolean]("attachments_only", this)
val counter = Column[Int]("counter", this)
val enabled = Column[Boolean]("enabled", this)
val priority = Column[Priority]("priority", this)
val created = Column[Timestamp]("created", this)
val folder = Column[Ident]("folder_id", this)
val fileFilter = Column[Glob]("file_filter", this)
val language = Column[Language]("doc_lang", this)
val attachOnly = Column[Boolean]("attachments_only", this)
val all =
NonEmptyList.of[Column[_]](

View File

@ -28,12 +28,12 @@ object RTag {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "tag"
val tid = Column[Ident]("tid", this)
val cid = Column[Ident]("cid", this)
val name = Column[String]("name", this)
val tid = Column[Ident]("tid", this)
val cid = Column[Ident]("cid", this)
val name = Column[String]("name", this)
val category = Column[String]("category", this)
val created = Column[Timestamp]("created", this)
val all = NonEmptyList.of[Column[_]](tid, cid, name, category, created)
val created = Column[Timestamp]("created", this)
val all = NonEmptyList.of[Column[_]](tid, cid, name, category, created)
}
val T = Table(None)
def as(alias: String): Table =
@ -97,7 +97,7 @@ object RTag {
def findByItem(itemId: Ident): ConnectionIO[Vector[RTag]] = {
val ti = RTagItem.as("i")
val t = RTag.as("t")
val t = RTag.as("t")
val sql =
Select(
select(t.all),

View File

@ -23,9 +23,9 @@ object RTagItem {
val tableName = "tagitem"
val tagItemId = Column[Ident]("tagitemid", this)
val itemId = Column[Ident]("itemid", this)
val tagId = Column[Ident]("tid", this)
val all = NonEmptyList.of[Column[_]](tagItemId, itemId, tagId)
val itemId = Column[Ident]("itemid", this)
val tagId = Column[Ident]("tid", this)
val all = NonEmptyList.of[Column[_]](tagItemId, itemId, tagId)
}
val T = Table(None)
def as(alias: String): Table =

View File

@ -23,10 +23,10 @@ object RTagSource {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "tagsource"
val id = Column[Ident]("id", this)
val id = Column[Ident]("id", this)
val sourceId = Column[Ident]("source_id", this)
val tagId = Column[Ident]("tag_id", this)
val all = NonEmptyList.of[Column[_]](id, sourceId, tagId)
val tagId = Column[Ident]("tag_id", this)
val all = NonEmptyList.of[Column[_]](id, sourceId, tagId)
}
private val t = Table(None)

View File

@ -29,9 +29,9 @@ object RTotp {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "totp"
val userId = Column[Ident]("user_id", this)
val userId = Column[Ident]("user_id", this)
val enabled = Column[Boolean]("enabled", this)
val secret = Column[Key]("secret", this)
val secret = Column[Key]("secret", this)
val created = Column[Timestamp]("created", this)
val all = Nel.of(userId, enabled, secret, created)

View File

@ -54,16 +54,16 @@ object RUser {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "user_"
val uid = Column[Ident]("uid", this)
val login = Column[Ident]("login", this)
val cid = Column[Ident]("cid", this)
val password = Column[Password]("password", this)
val state = Column[UserState]("state", this)
val source = Column[AccountSource]("account_source", this)
val email = Column[String]("email", this)
val uid = Column[Ident]("uid", this)
val login = Column[Ident]("login", this)
val cid = Column[Ident]("cid", this)
val password = Column[Password]("password", this)
val state = Column[UserState]("state", this)
val source = Column[AccountSource]("account_source", this)
val email = Column[String]("email", this)
val loginCount = Column[Int]("logincount", this)
val lastLogin = Column[Timestamp]("lastlogin", this)
val created = Column[Timestamp]("created", this)
val lastLogin = Column[Timestamp]("lastlogin", this)
val created = Column[Timestamp]("created", this)
val all =
NonEmptyList.of[Column[_]](
@ -121,13 +121,13 @@ object RUser {
}
def findById(userId: Ident): ConnectionIO[Option[RUser]] = {
val t = Table(None)
val t = Table(None)
val sql = run(select(t.all), from(t), t.uid === userId)
sql.query[RUser].option
}
def findAll(coll: Ident, order: Table => Column[_]): ConnectionIO[Vector[RUser]] = {
val t = Table(None)
val t = Table(None)
val sql = Select(select(t.all), from(t), t.cid === coll).orderBy(order(t)).build
sql.query[RUser].to[Vector]
}

View File

@ -61,7 +61,7 @@ object RUserEmail {
): F[RUserEmail] =
for {
now <- Timestamp.current[F]
id <- Ident.randomId[F]
id <- Ident.randomId[F]
} yield RUserEmail(
id,
uid,
@ -90,8 +90,8 @@ object RUserEmail {
mailReplyTo: Option[MailAddress]
): OptionT[ConnectionIO, RUserEmail] =
for {
now <- OptionT.liftF(Timestamp.current[ConnectionIO])
id <- OptionT.liftF(Ident.randomId[ConnectionIO])
now <- OptionT.liftF(Timestamp.current[ConnectionIO])
id <- OptionT.liftF(Ident.randomId[ConnectionIO])
user <- OptionT(RUser.findByAccount(accId))
} yield RUserEmail(
id,
@ -111,18 +111,18 @@ object RUserEmail {
val tableName = "useremail"
val id = Column[Ident]("id", this)
val uid = Column[Ident]("uid", this)
val name = Column[Ident]("name", this)
val smtpHost = Column[String]("smtp_host", this)
val smtpPort = Column[Int]("smtp_port", this)
val smtpUser = Column[String]("smtp_user", this)
val smtpPass = Column[Password]("smtp_password", this)
val smtpSsl = Column[SSLType]("smtp_ssl", this)
val id = Column[Ident]("id", this)
val uid = Column[Ident]("uid", this)
val name = Column[Ident]("name", this)
val smtpHost = Column[String]("smtp_host", this)
val smtpPort = Column[Int]("smtp_port", this)
val smtpUser = Column[String]("smtp_user", this)
val smtpPass = Column[Password]("smtp_password", this)
val smtpSsl = Column[SSLType]("smtp_ssl", this)
val smtpCertCheck = Column[Boolean]("smtp_certcheck", this)
val mailFrom = Column[MailAddress]("mail_from", this)
val mailReplyTo = Column[MailAddress]("mail_replyto", this)
val created = Column[Timestamp]("created", this)
val mailFrom = Column[MailAddress]("mail_from", this)
val mailReplyTo = Column[MailAddress]("mail_replyto", this)
val created = Column[Timestamp]("created", this)
val all = NonEmptyList.of[Column[_]](
id,
@ -181,7 +181,7 @@ object RUserEmail {
nameQ: Option[String],
exact: Boolean
): Query0[RUserEmail] = {
val user = RUser.as("u")
val user = RUser.as("u")
val email = as("m")
val nameFilter = nameQ.map(s =>

View File

@ -60,7 +60,7 @@ object RUserImap {
): F[RUserImap] =
for {
now <- Timestamp.current[F]
id <- Ident.randomId[F]
id <- Ident.randomId[F]
} yield RUserImap(
id,
uid,
@ -87,8 +87,8 @@ object RUserImap {
imapOAuth2: Boolean
): OptionT[ConnectionIO, RUserImap] =
for {
now <- OptionT.liftF(Timestamp.current[ConnectionIO])
id <- OptionT.liftF(Ident.randomId[ConnectionIO])
now <- OptionT.liftF(Timestamp.current[ConnectionIO])
id <- OptionT.liftF(Ident.randomId[ConnectionIO])
user <- OptionT(RUser.findByAccount(accId))
} yield RUserImap(
id,
@ -107,17 +107,17 @@ object RUserImap {
final case class Table(alias: Option[String]) extends TableDef {
val tableName = "userimap"
val id = Column[Ident]("id", this)
val uid = Column[Ident]("uid", this)
val name = Column[Ident]("name", this)
val imapHost = Column[String]("imap_host", this)
val imapPort = Column[Int]("imap_port", this)
val imapUser = Column[String]("imap_user", this)
val imapPass = Column[Password]("imap_password", this)
val imapSsl = Column[SSLType]("imap_ssl", this)
val id = Column[Ident]("id", this)
val uid = Column[Ident]("uid", this)
val name = Column[Ident]("name", this)
val imapHost = Column[String]("imap_host", this)
val imapPort = Column[Int]("imap_port", this)
val imapUser = Column[String]("imap_user", this)
val imapPass = Column[Password]("imap_password", this)
val imapSsl = Column[SSLType]("imap_ssl", this)
val imapCertCheck = Column[Boolean]("imap_certcheck", this)
val imapOAuth2 = Column[Boolean]("imap_oauth2", this)
val created = Column[Timestamp]("created", this)
val imapOAuth2 = Column[Boolean]("imap_oauth2", this)
val created = Column[Timestamp]("created", this)
val all = NonEmptyList.of[Column[_]](
id,

View File

@ -17,8 +17,7 @@ import docspell.store.qb._
import doobie._
import doobie.implicits._
/** Combines a source record (RSource) and a list of associated tags.
*/
/** Combines a source record (RSource) and a list of associated tags. */
case class SourceData(source: RSource, tags: Vector[RTag])
object SourceData {
@ -56,9 +55,9 @@ object SourceData {
for {
resolvedTags <- Stream.eval(Ref.of[ConnectionIO, Map[Ident, RTag]](Map.empty))
source <- select
tagSources <- Stream.eval(RTagSource.findBySource(source.sid))
tags <- Stream.eval(tagSources.traverse(ti => findTag(resolvedTags, ti)))
source <- select
tagSources <- Stream.eval(RTagSource.findBySource(source.sid))
tags <- Stream.eval(tagSources.traverse(ti => findTag(resolvedTags, ti)))
} yield SourceData(source, tags.flatten)
}
@ -67,7 +66,7 @@ object SourceData {
def insert(data: RSource, tags: List[String]): ConnectionIO[Int] =
for {
n0 <- RSource.insert(data)
n0 <- RSource.insert(data)
tags <- RTag.findAllByNameOrId(tags, data.cid)
n1 <- tags.traverse(tag =>
RTagSource.createNew[ConnectionIO](data.sid, tag.tagId).flatMap(RTagSource.insert)
@ -76,9 +75,9 @@ object SourceData {
def update(data: RSource, tags: List[String]): ConnectionIO[Int] =
for {
n0 <- RSource.updateNoCounter(data)
n0 <- RSource.updateNoCounter(data)
tags <- RTag.findAllByNameOrId(tags, data.cid)
_ <- RTagSource.deleteSourceTags(data.sid)
_ <- RTagSource.deleteSourceTags(data.sid)
n1 <- tags.traverse(tag =>
RTagSource.createNew[ConnectionIO](data.sid, tag.tagId).flatMap(RTagSource.insert)
)

View File

@ -26,7 +26,7 @@ case class TagItemName(
object TagItemName {
private val ti = RTagItem.as("ti")
private val t = RTag.as("t")
private val t = RTag.as("t")
private val taggedItems =
from(t).innerJoin(ti, t.tid === ti.tagId)

View File

@ -33,8 +33,7 @@ import io.circe._
*/
trait UserTaskStore[F[_]] {
/** Return all tasks of the given user.
*/
/** Return all tasks of the given user. */
def getAll(scope: UserTaskScope): Stream[F, UserTask[String]]
/** Return all tasks of the given name and user. The task's arguments are returned as
@ -61,8 +60,7 @@ trait UserTaskStore[F[_]] {
implicit E: Encoder[A]
): F[Int]
/** Delete the task with the given id of the given user.
*/
/** Delete the task with the given id of the given user. */
def deleteTask(scope: UserTaskScope, id: Ident): F[Int]
/** Return the task of the given user and name. If multiple exists, an error is
@ -91,8 +89,7 @@ trait UserTaskStore[F[_]] {
implicit E: Encoder[A]
): F[UserTask[String]]
/** Delete all tasks of the given user that have name `name'.
*/
/** Delete all tasks of the given user that have name `name'. */
def deleteAll(scope: UserTaskScope, name: Ident): F[Int]
}

View File

@ -26,7 +26,7 @@ trait StoreFixture extends CatsEffectFunFixtures { self: CatsEffectSuite =>
for {
ds <- StoreFixture.dataSource(cfg)
xa <- StoreFixture.makeXA(ds)
_ <- Resource.eval(FlywayMigrate.run[IO](cfg))
_ <- Resource.eval(FlywayMigrate.run[IO](cfg))
} yield xa
}
@ -34,7 +34,7 @@ trait StoreFixture extends CatsEffectFunFixtures { self: CatsEffectSuite =>
val cfg = StoreFixture.memoryDB("test")
for {
store <- StoreFixture.store(cfg)
_ <- Resource.eval(store.migrate)
_ <- Resource.eval(store.migrate)
} yield store
}
}

View File

@ -51,14 +51,14 @@ class ItemQueryGeneratorTest extends FunSuite {
}
test("!conc:*") {
val q = ItemQueryParser.parseUnsafe("!conc:*")
val cond = ItemQueryGenerator(now, tables, Ident.unsafe("coll"))(q)
val q = ItemQueryParser.parseUnsafe("!conc:*")
val cond = ItemQueryGenerator(now, tables, Ident.unsafe("coll"))(q)
val expect = not(tables.concPers.name.like("%") || tables.concEquip.name.like("%"))
assertEquals(cond, expect)
}
test("attach.id with wildcard") {
val q = ItemQueryParser.parseUnsafe("attach.id=abcde*")
val q = ItemQueryParser.parseUnsafe("attach.id=abcde*")
val cond = ItemQueryGenerator(now, tables, Ident.unsafe("coll"))(q)
val expect = tables.item.id.in(
Select(
@ -72,7 +72,7 @@ class ItemQueryGeneratorTest extends FunSuite {
}
test("attach.id with equals") {
val q = ItemQueryParser.parseUnsafe("attach.id=abcde")
val q = ItemQueryParser.parseUnsafe("attach.id=abcde")
val cond = ItemQueryGenerator(now, tables, Ident.unsafe("coll"))(q)
val expect = tables.item.id.in(
Select(

View File

@ -16,7 +16,7 @@ import munit.FunSuite
class H2MigrateTest extends FunSuite {
test("h2 empty schema migration") {
val jdbc = StoreFixture.memoryDB("h2test")
val jdbc = StoreFixture.memoryDB("h2test")
val result = FlywayMigrate.run[IO](jdbc).unsafeRunSync()
assert(result.migrationsExecuted > 0)
}

View File

@ -14,8 +14,8 @@ import munit._
class QueryBuilderTest extends FunSuite {
test("simple") {
val c = CourseRecord.as("c")
val owner = PersonRecord.as("p1")
val c = CourseRecord.as("c")
val owner = PersonRecord.as("p1")
val lecturer = PersonRecord.as("p2")
val proj = select(c.all, owner.all, lecturer.all)

View File

@ -15,8 +15,8 @@ import munit._
class SelectBuilderTest extends FunSuite {
test("basic fragment") {
val c = CourseRecord.as("c")
val owner = PersonRecord.as("o")
val c = CourseRecord.as("c")
val owner = PersonRecord.as("o")
val lecturer = PersonRecord.as("l")
val proj = select(c.all)
@ -28,7 +28,7 @@ class SelectBuilderTest extends FunSuite {
owner.name === "Harald"
)
val q = Select(proj, table, cond)
val q = Select(proj, table, cond)
val frag = SelectBuilder(q)
assertEquals(
frag.toString,

View File

@ -24,11 +24,11 @@ object CourseRecord {
override val tableName = "course"
val id = Column[Long]("id", this)
val name = Column[String]("name", this)
val ownerId = Column[Long]("owner_id", this)
val id = Column[Long]("id", this)
val name = Column[String]("name", this)
val ownerId = Column[Long]("owner_id", this)
val lecturerId = Column[Long]("lecturer_id", this)
val lessons = Column[Int]("lessons", this)
val lessons = Column[Int]("lessons", this)
val all = NonEmptyList.of[Column[_]](id, name, ownerId, lecturerId, lessons)
}

View File

@ -19,8 +19,8 @@ object PersonRecord {
val tableName = "person"
val id = Column[Long]("id", this)
val name = Column[String]("name", this)
val id = Column[Long]("id", this)
val name = Column[String]("name", this)
val created = Column[Timestamp]("created", this)
val all = NonEmptyList.of[Column[_]](id, name, created)

View File

@ -22,11 +22,11 @@ import munit._
class QJobTest extends CatsEffectSuite with StoreFixture {
private[this] val c = new AtomicLong(0)
private val worker = Ident.unsafe("joex1")
private val worker = Ident.unsafe("joex1")
private val initialPause = Duration.seconds(5)
private val nowTs = Timestamp(Instant.parse("2021-06-26T14:54:00Z"))
private val group1 = Ident.unsafe("group1")
private val group2 = Ident.unsafe("group2")
private val nowTs = Timestamp(Instant.parse("2021-06-26T14:54:00Z"))
private val group1 = Ident.unsafe("group1")
private val group2 = Ident.unsafe("group2")
def createJob(group: Ident): RJob =
RJob.newJob[Unit](
@ -44,7 +44,7 @@ class QJobTest extends CatsEffectSuite with StoreFixture {
xa.test("set group must insert or update") { tx =>
val res =
for {
_ <- RJobGroupUse.setGroup(RJobGroupUse(group1, worker)).transact(tx)
_ <- RJobGroupUse.setGroup(RJobGroupUse(group1, worker)).transact(tx)
res <- RJobGroupUse.findGroup(worker).transact(tx)
} yield res
@ -57,7 +57,7 @@ class QJobTest extends CatsEffectSuite with StoreFixture {
.map(createJob)
.map(RJob.insert)
.traverse(_.transact(tx))
_ <- RJobGroupUse.deleteAll.transact(tx)
_ <- RJobGroupUse.deleteAll.transact(tx)
next <- QJob.selectNextGroup(worker, nowTs, initialPause).transact(tx)
} yield next
@ -70,8 +70,8 @@ class QJobTest extends CatsEffectSuite with StoreFixture {
.map(createJob)
.map(RJob.insert)
.traverse(_.transact(tx))
_ <- RJobGroupUse.deleteAll.transact(tx)
_ <- RJobGroupUse.setGroup(RJobGroupUse(group1, worker)).transact(tx)
_ <- RJobGroupUse.deleteAll.transact(tx)
_ <- RJobGroupUse.setGroup(RJobGroupUse(group1, worker)).transact(tx)
next <- QJob.selectNextGroup(worker, nowTs, initialPause).transact(tx)
} yield next
@ -84,8 +84,8 @@ class QJobTest extends CatsEffectSuite with StoreFixture {
.map(createJob)
.map(RJob.insert)
.traverse(_.transact(tx))
_ <- RJobGroupUse.deleteAll.transact(tx)
_ <- RJobGroupUse.setGroup(RJobGroupUse(group2, worker)).transact(tx)
_ <- RJobGroupUse.deleteAll.transact(tx)
_ <- RJobGroupUse.setGroup(RJobGroupUse(group2, worker)).transact(tx)
next <- QJob.selectNextGroup(worker, nowTs, initialPause).transact(tx)
} yield next