Skip to content

Commit

Permalink
adapt get size query
Browse files Browse the repository at this point in the history
  • Loading branch information
zingmane committed May 17, 2024
1 parent f3bb3e2 commit 2a4ed7e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ class TableauxModel(
implicit user: TableauxUser
): Future[RowSeq] = {
for {
totalSize <- retrieveRowModel.size(table.id)
totalSize <- retrieveRowModel.size(table.id, finalFlagOpt, archivedFlagOpt)
rawRows <- retrieveRowModel.retrieveAll(table.id, columns, finalFlagOpt, archivedFlagOpt, pagination)
rowSeq <- mapRawRows(table, columns, rawRows)
} yield {
Expand Down Expand Up @@ -1575,8 +1575,12 @@ class TableauxModel(
} yield values
}

def retrieveTotalSize(table: Table): Future[Long] = {
retrieveRowModel.size(table.id)
def retrieveTotalSize(
table: Table,
finalFlagOpt: Option[Boolean] = None,
archivedFlagOpt: Option[Boolean] = None
): Future[Long] = {
retrieveRowModel.size(table.id, finalFlagOpt, archivedFlagOpt)
}

def retrieveCellHistory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1279,10 +1279,11 @@ class RetrieveRowModel(val connection: DatabaseConnection)(
}
}

def size(tableId: TableId): Future[Long] = {
val select = s"SELECT COUNT(*) FROM user_table_$tableId"
def size(tableId: TableId, finalFlagOpt: Option[Boolean], archivedFlagOpt: Option[Boolean]): Future[Long] = {
val whereClause = generateRowAnnotationWhereClause(finalFlagOpt, archivedFlagOpt)
val query = s"SELECT COUNT(*) FROM user_table_$tableId WHERE TRUE $whereClause"

connection.selectSingleValue(select)
connection.selectSingleValue(query)
}

def sizeForeign(linkColumn: LinkColumn, rowId: RowId, linkDirection: LinkDirection): Future[Long] = {
Expand Down

0 comments on commit 2a4ed7e

Please sign in to comment.