Working kimai filtering, diable requests_cache for now
This commit is contained in:
parent
4b85921b3e
commit
65f16a252c
@ -193,9 +193,7 @@ class KimaiScreen(ListScreen):
|
||||
def _refresh(self, filter_query=None):
|
||||
self.table.clear()
|
||||
|
||||
projects = KimaiProject.list(
|
||||
self.db_manager
|
||||
)
|
||||
projects = KimaiProject.list(self.db_manager, filter_query)
|
||||
|
||||
self.table.add_rows(
|
||||
[
|
||||
|
@ -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]
|
||||
|
@ -1,5 +1,5 @@
|
||||
import requests
|
||||
import requests_cache
|
||||
# import requests_cache
|
||||
import os
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ class KimaiAPI(object):
|
||||
}
|
||||
|
||||
def __init__(self):
|
||||
requests_cache.install_cache('kimai', backend='sqlite', expire_after=1800)
|
||||
# requests_cache.install_cache('kimai', backend='sqlite', expire_after=1800)
|
||||
self.customers_json = requests.get(
|
||||
f'{self.KIMAI_API_URL}/customers?visible=3', headers=self.auth_headers).json()
|
||||
self.projects_json = requests.get(
|
||||
|
Loading…
Reference in New Issue
Block a user