mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-05 02:49:32 +00:00
Rename methods
This commit is contained in:
parent
978381a5ba
commit
c79bdad7e4
@ -62,7 +62,7 @@ object PeriodicQueryTask {
|
|||||||
private def queryString(q: ItemQuery.Expr) =
|
private def queryString(q: ItemQuery.Expr) =
|
||||||
ItemQueryParser.asString(q)
|
ItemQueryParser.asString(q)
|
||||||
|
|
||||||
def makeQuery[F[_]: Sync](ctx: Context[F, Args])(cont: Query => F[Unit]): F[Unit] = {
|
def withQuery[F[_]: Sync](ctx: Context[F, Args])(cont: Query => F[Unit]): F[Unit] = {
|
||||||
def fromBookmark(id: String) =
|
def fromBookmark(id: String) =
|
||||||
ctx.store
|
ctx.store
|
||||||
.transact(RQueryBookmark.findByNameOrId(ctx.args.account, id))
|
.transact(RQueryBookmark.findByNameOrId(ctx.args.account, id))
|
||||||
@ -82,7 +82,7 @@ object PeriodicQueryTask {
|
|||||||
def fromBookmarkOrShare(id: String) =
|
def fromBookmarkOrShare(id: String) =
|
||||||
OptionT(fromBookmark(id)).orElse(OptionT(fromShare(id))).value
|
OptionT(fromBookmark(id)).orElse(OptionT(fromShare(id))).value
|
||||||
|
|
||||||
def withQuery(bm: Option[ItemQuery], str: String): F[Unit] =
|
def runQuery(bm: Option[ItemQuery], str: String): F[Unit] =
|
||||||
ItemQueryParser.parse(str) match {
|
ItemQueryParser.parse(str) match {
|
||||||
case Right(q) =>
|
case Right(q) =>
|
||||||
val expr = bm.map(b => AndExpr(Nel.of(b.expr, q.expr))).getOrElse(q.expr)
|
val expr = bm.map(b => AndExpr(Nel.of(b.expr, q.expr))).getOrElse(q.expr)
|
||||||
@ -98,7 +98,7 @@ object PeriodicQueryTask {
|
|||||||
(ctx.args.bookmark, ctx.args.query) match {
|
(ctx.args.bookmark, ctx.args.query) match {
|
||||||
case (Some(bm), Some(qstr)) =>
|
case (Some(bm), Some(qstr)) =>
|
||||||
ctx.logger.debug(s"Using bookmark $bm and query $qstr") *>
|
ctx.logger.debug(s"Using bookmark $bm and query $qstr") *>
|
||||||
fromBookmarkOrShare(bm).flatMap(bq => withQuery(bq, qstr.query))
|
fromBookmarkOrShare(bm).flatMap(bq => runQuery(bq, qstr.query))
|
||||||
|
|
||||||
case (Some(bm), None) =>
|
case (Some(bm), None) =>
|
||||||
fromBookmarkOrShare(bm).flatMap {
|
fromBookmarkOrShare(bm).flatMap {
|
||||||
@ -113,7 +113,7 @@ object PeriodicQueryTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case (None, Some(qstr)) =>
|
case (None, Some(qstr)) =>
|
||||||
ctx.logger.debug(s"Using query: ${qstr.query}") *> withQuery(None, qstr.query)
|
ctx.logger.debug(s"Using query: ${qstr.query}") *> runQuery(None, qstr.query)
|
||||||
|
|
||||||
case (None, None) =>
|
case (None, None) =>
|
||||||
ctx.logger.error(s"No query provided for task $taskName!")
|
ctx.logger.error(s"No query provided for task $taskName!")
|
||||||
@ -123,7 +123,7 @@ object PeriodicQueryTask {
|
|||||||
def withItems[F[_]: Sync](ctx: Context[F, Args], limit: Int, now: Timestamp)(
|
def withItems[F[_]: Sync](ctx: Context[F, Args], limit: Int, now: Timestamp)(
|
||||||
cont: Vector[ListItem] => F[Unit]
|
cont: Vector[ListItem] => F[Unit]
|
||||||
): F[Unit] =
|
): F[Unit] =
|
||||||
makeQuery(ctx) { query =>
|
withQuery(ctx) { query =>
|
||||||
val items = ctx.store
|
val items = ctx.store
|
||||||
.transact(QItem.findItems(query, now.toUtcDate, 0, Batch.limit(limit)))
|
.transact(QItem.findItems(query, now.toUtcDate, 0, Batch.limit(limit)))
|
||||||
.compile
|
.compile
|
||||||
|
Loading…
x
Reference in New Issue
Block a user