mirror of
https://github.com/pretix/pretix.git
synced 2026-05-06 15:24:02 +00:00
Metrics: Fail silently if estimated count returns no result
This commit is contained in:
@@ -249,6 +249,8 @@ def estimate_count_fast(type):
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("select reltuples from pg_class where relname='%s';" % type._meta.db_table)
|
||||
row = cursor.fetchone()
|
||||
if not row:
|
||||
return 0
|
||||
return int(row[0])
|
||||
else:
|
||||
return type.objects.count()
|
||||
|
||||
Reference in New Issue
Block a user