WIP usage info table

Might get replaced with gradio depending on how well it works
This commit is contained in:
DominikDoom
2023-12-04 15:00:19 +01:00
parent 1fe8f26670
commit 20b6635a2a
3 changed files with 56 additions and 10 deletions

View File

@@ -634,7 +634,7 @@ def api_tac(_: gr.Blocks, app: FastAPI):
db_request(lambda: db.reset_tag_count(tagname, ttype, pos, neg))
@app.get("/tacapi/v1/get-all-use-counts")
async def get_all_tag_counts(neg: bool = False):
return db_request(lambda: db.get_all_tags(neg), get=True)
async def get_all_tag_counts():
return db_request(lambda: db.get_all_tags(), get=True)
script_callbacks.on_app_started(api_tac)

View File

@@ -86,14 +86,14 @@ class TagFrequencyDb:
return db_version[0] if db_version else 0
def get_all_tags(self, negative=False):
count_str = "count_neg" if negative else "count_pos"
def get_all_tags(self):
with transaction() as cursor:
cursor.execute(
f"""
SELECT name, type, {count_str}, last_used
SELECT name, type, count_pos, count_neg, last_used
FROM tag_frequency
ORDER BY {count_str} DESC
WHERE count_pos > 0 OR count_neg > 0
ORDER BY count_pos + count_neg DESC
"""
)
tags = cursor.fetchall()