Working kimai filtering, diable requests_cache for now
This commit is contained in:
@ -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]
|
||||
|
Reference in New Issue
Block a user