exclude system token more places
This commit is contained in:
parent
bbdb9c9d55
commit
e37cde5d48
|
@ -68,7 +68,7 @@ def get_number_of_rows(table_name):
|
|||
conn = db_pool.connection()
|
||||
cursor = conn.cursor()
|
||||
try:
|
||||
cursor.execute(f'SELECT COUNT(*) FROM {table_name}')
|
||||
cursor.execute(f"SELECT COUNT(*) FROM {table_name} WHERE token NOT LIKE 'SYSTEM__%%' OR token IS NULL")
|
||||
result = cursor.fetchone()
|
||||
return result[0]
|
||||
finally:
|
||||
|
@ -79,7 +79,7 @@ def average_column(table_name, column_name):
|
|||
conn = db_pool.connection()
|
||||
cursor = conn.cursor()
|
||||
try:
|
||||
cursor.execute(f"SELECT AVG({column_name}) FROM {table_name}")
|
||||
cursor.execute(f"SELECT AVG({column_name}) FROM {table_name} WHERE token NOT LIKE 'SYSTEM__%%' OR token IS NULL")
|
||||
result = cursor.fetchone()
|
||||
return result[0]
|
||||
finally:
|
||||
|
@ -90,7 +90,7 @@ def average_column_for_model(table_name, column_name, model_name):
|
|||
conn = db_pool.connection()
|
||||
cursor = conn.cursor()
|
||||
try:
|
||||
cursor.execute(f"SELECT AVG({column_name}) FROM {table_name} WHERE model = %s", (model_name,))
|
||||
cursor.execute(f"SELECT AVG({column_name}) FROM {table_name} WHERE model = %s AND token NOT LIKE 'SYSTEM__%%' OR token IS NULL", (model_name,))
|
||||
result = cursor.fetchone()
|
||||
return result[0]
|
||||
finally:
|
||||
|
@ -102,7 +102,7 @@ def weighted_average_column_for_model(table_name, column_name, model_name, backe
|
|||
cursor = conn.cursor()
|
||||
try:
|
||||
try:
|
||||
cursor.execute(f"SELECT {column_name}, id FROM {table_name} WHERE model = %s AND backend_mode = %s AND backend_url = %s AND token NOT LIKE 'SYSTEM__%%' ORDER BY id DESC", (model_name, backend_name, backend_url,))
|
||||
cursor.execute(f"SELECT {column_name}, id FROM {table_name} WHERE model = %s AND backend_mode = %s AND backend_url = %s AND (token NOT LIKE 'SYSTEM__%%' OR token IS NULL) ORDER BY id DESC", (model_name, backend_name, backend_url,))
|
||||
results = cursor.fetchall()
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
@ -132,7 +132,7 @@ def sum_column(table_name, column_name):
|
|||
conn = db_pool.connection()
|
||||
cursor = conn.cursor()
|
||||
try:
|
||||
cursor.execute(f"SELECT SUM({column_name}) FROM {table_name} WHERE token NOT LIKE 'SYSTEM__%%'")
|
||||
cursor.execute(f"SELECT SUM({column_name}) FROM {table_name} WHERE token NOT LIKE 'SYSTEM__%%' OR token IS NULL")
|
||||
result = cursor.fetchone()
|
||||
return result[0] if result else 0
|
||||
finally:
|
||||
|
|
Reference in New Issue