diff --git a/src/main/scala/com/campudus/tableaux/database/model/TableauxModel.scala b/src/main/scala/com/campudus/tableaux/database/model/TableauxModel.scala index 48c77d1c..1cac50ba 100644 --- a/src/main/scala/com/campudus/tableaux/database/model/TableauxModel.scala +++ b/src/main/scala/com/campudus/tableaux/database/model/TableauxModel.scala @@ -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 { @@ -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( diff --git a/src/main/scala/com/campudus/tableaux/database/model/tableaux/RowModel.scala b/src/main/scala/com/campudus/tableaux/database/model/tableaux/RowModel.scala index 19eaeb80..a96e05db 100644 --- a/src/main/scala/com/campudus/tableaux/database/model/tableaux/RowModel.scala +++ b/src/main/scala/com/campudus/tableaux/database/model/tableaux/RowModel.scala @@ -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] = {