-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathNoveltyQuery.scala
More file actions
43 lines (38 loc) · 1.07 KB
/
NoveltyQuery.scala
File metadata and controls
43 lines (38 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package models.db
import esecuele.Column.column
import esecuele.Column.literal
import esecuele.*
import utils.OTLogging
case class NoveltyQuery(diseaseId: String,
targetId: String,
isDirect: Boolean,
tableName: String,
offset: Int,
size: Int
) extends Queryable
with OTLogging {
private val positionalQuery = Where(
Functions.and(
Functions.equals(column("diseaseId"), literal(diseaseId)),
Functions.equals(column("targetId"), literal(targetId)),
Functions.equals(column("isDirect"), literal(isDirect))
)
)
val totals: Query =
Query(
Select(Functions.count(Column.star) :: Nil),
From(column(tableName)),
positionalQuery
)
override val query: Query =
Query(
Select(
Column.star :: Functions.countOver("meta_total") :: Nil
),
From(column(tableName)),
positionalQuery,
OrderBy(column("year").asc :: Nil),
Limit(offset, size),
Format("JSONEachRow")
)
}