0.1.4s
This commit is contained in:
+9
-7
@@ -1,8 +1,10 @@
|
||||
import sqlite3
|
||||
import os
|
||||
import json
|
||||
import os
|
||||
import sqlite3
|
||||
from datetime import datetime
|
||||
from system_module import gelbooru
|
||||
|
||||
from system_module.gelbooru import gelbooru_date_parse
|
||||
|
||||
|
||||
class DB:
|
||||
def __init__(self, debug: bool):
|
||||
@@ -117,7 +119,7 @@ class DB:
|
||||
"score": data_add["score"],
|
||||
"timestamp": data_add["created_at"],
|
||||
"parsed_time": parsed_time,
|
||||
"display_date": gelbooru.gelbooru_date_parse(data_add["created_at"]),
|
||||
"display_date": gelbooru_date_parse(data_add["created_at"]),
|
||||
"source": data_add["source"],
|
||||
"width": data_add["width"],
|
||||
"height": data_add["height"]
|
||||
@@ -165,15 +167,15 @@ class DB:
|
||||
cursor = self.conn.execute(query, (md5,))
|
||||
return cursor.fetchone() is not None
|
||||
|
||||
def get_autocomplete(self, tag_slise: str):
|
||||
def get_top_tag(self, tag_slise: str, count_tag_get: int = 9999999):
|
||||
query = """
|
||||
SELECT value AS tag, COUNT(*) AS count
|
||||
FROM files, json_each(files.tags)
|
||||
WHERE value LIKE ?
|
||||
GROUP BY value
|
||||
ORDER BY count DESC
|
||||
LIMIT 10
|
||||
"""
|
||||
LIMIT {count_tag_get}
|
||||
""".format(count_tag_get=count_tag_get)
|
||||
cursor = self.conn.execute(query, (f"{tag_slise.lower()}%",))
|
||||
return [{"tag": row["tag"], "count": row["count"]} for row in cursor.fetchall()]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user