mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
EventsDB: count by retrieving the rows instead of using COUNT
This commit is contained in:
parent
96887483e8
commit
6ee8d4ab47
1 changed files with 2 additions and 7 deletions
|
|
@ -341,15 +341,10 @@ class EventsDB implements NStore {
|
||||||
if (!filters.length) return Promise.resolve({ count: 0, approximate: false });
|
if (!filters.length) return Promise.resolve({ count: 0, approximate: false });
|
||||||
|
|
||||||
this.#debug('COUNT', JSON.stringify(filters));
|
this.#debug('COUNT', JSON.stringify(filters));
|
||||||
const query = this.getEventsQuery(filters);
|
const results = await this.query(filters);
|
||||||
|
|
||||||
const [{ count }] = await query
|
|
||||||
.clearSelect()
|
|
||||||
.select((eb) => eb.fn.count('id').as('count'))
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
count: Number(count),
|
count: results.length,
|
||||||
approximate: false,
|
approximate: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue