Working kimai filtering, diable requests_cache for now

This commit is contained in:
3wc
2023-10-27 23:27:48 +01:00
parent 4b85921b3e
commit 65f16a252c
3 changed files with 16 additions and 10 deletions

View File

@ -242,9 +242,13 @@ class KimaiProject(BaseORM):
self.db_manager.get_conn().commit()
@staticmethod
def list(db_manager):
def list(db_manager, filter_query=None):
cursor = db_manager.get_cursor()
cursor.execute("""
where = ""
if filter_query is not None:
where = "WHERE kimai_projects.name LIKE ? or kimai_customers.name like ?"
sql = f"""
SELECT
kimai_projects.id,
COALESCE(kimai_projects.name, ""),
@ -256,9 +260,13 @@ class KimaiProject(BaseORM):
kimai_customers
ON
kimai_customers.id = kimai_projects.customer_id
GROUP BY
kimai_customers.id
""")
{where}
"""
if filter_query is not None:
cursor.execute(sql, ("%{}%".format(filter_query),) * 2)
else:
cursor.execute(sql)
rows = cursor.fetchall()
return [KimaiProject(db_manager, row[0], row[1], row[2], row[3]) for row in rows]