Skip to content
Snippets Groups Projects

Resolve "Backend code update"

Merged Lidiya Gelemeev requested to merge 4-backend-code-update into main
2 files
+ 32
80
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -15,23 +15,15 @@ class ExternalSharesMapper extends ExtMapper {
}
public function queryTotalCount() {
$data = [
'count' => 0
];
$this->chunkedQuery('id', array($this, 'queryTotalCountCallback'), $data);
return $data['count'];
}
protected function queryTotalCountCallback(IQueryBuilder $query, $offset, &$data): int {
$query->selectAlias($query->createFunction('COUNT(*)'), 'c')
->selectAlias($query->createFunction('MAX(id)'), 'm')
->from(self::EXTERNAL_SHARES_TABLE);
$this->addChunkCondition($query,'id', $offset, true);
// Query values and add up count
$values = $this->queryValues($query, ['c', 'm']);
$data['count'] += $values['c'];
return $values['m'] == NULL ? 0 : $values['m'];
}
$query = $this->db->getQueryBuilder();
// Create a query to count all rows in the EXTERNAL_SHARES_TABLE
$query->selectAlias($query->createFunction('COUNT(*)'), 'count')
->from(self::EXTERNAL_SHARES_TABLE);
// Execute the query and fetch the result
$result = $query->execute()->fetch();
// Return the total count as an integer
return (int) $result['count'];
}
Loading