mirror of
https://github.com/pretix/pretix.git
synced 2026-05-07 15:34: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 = connection.cursor()
|
||||||
cursor.execute("select reltuples from pg_class where relname='%s';" % type._meta.db_table)
|
cursor.execute("select reltuples from pg_class where relname='%s';" % type._meta.db_table)
|
||||||
row = cursor.fetchone()
|
row = cursor.fetchone()
|
||||||
|
if not row:
|
||||||
|
return 0
|
||||||
return int(row[0])
|
return int(row[0])
|
||||||
else:
|
else:
|
||||||
return type.objects.count()
|
return type.objects.count()
|
||||||
|
|||||||
Reference in New Issue
Block a user