diff --git a/.gitignore b/.gitignore index 36b13f1..faa9260 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # ---> Python # Byte-compiled / optimized / DLL files __pycache__/ +old/ *.py[cod] *$py.class diff --git a/datas/analytic.json b/datas/analytic.json new file mode 100644 index 0000000..527c676 --- /dev/null +++ b/datas/analytic.json @@ -0,0 +1,64 @@ +{ + "total_images_analyzed": 14003, + "average_weight": { + "bytes": 2980950.54, + "formatted": "2.84 MB" + }, + "storage_stats": { + "folders": { + "img": "38.88 GB", + "json_db": "24.39 MB", + "thumb": "331.45 MB", + "logs": "14.44 MB" + }, + "types_in_img": { + "images": "38.56 GB", + "videos": "140.80 MB", + "gifs": "181.30 MB", + "logs": "14.44 MB" + }, + "grand_total": "39.24 GB" + }, + "ratings_stats": { + "explicit": { + "count": 1605, + "size_formatted": "4.52 GB" + }, + "sensitive": { + "count": 6623, + "size_formatted": "19.35 GB" + }, + "questionable": { + "count": 1591, + "size_formatted": "4.72 GB" + }, + "general": { + "count": 4184, + "size_formatted": "10.29 GB" + } + }, + "resolution_stats": { + "largest": { + "filename": "5adc7e0e773417f9c379accf.png", + "md5": "5a63c28906dc7e0e7734c379accf", + "resolution": "9921x14031" + }, + "smallest": { + "filename": "8fc614e712ad21d2151ccde8a3c87.gif", + "md5": "8fc614e712ae22151ccde8a3c87", + "resolution": "240x280" + } + }, + "weight_stats": { + "largest": { + "filename": "4cf0a32c61c7e7914095d1fe.png", + "md5": "4ab6acf0a32c61c7e79fe", + "size_formatted": "65.21 MB" + }, + "smallest": { + "filename": "2e1c8a5870b90c3f538d7.png", + "md5": "28c679ea3470b90c3f538d7", + "size_formatted": "6.49 KB" + } + } +} \ No newline at end of file diff --git a/db.json b/db.json deleted file mode 100644 index 25f2254..0000000 --- a/db.json +++ /dev/null @@ -1 +0,0 @@ -{"_default": {"1": {"name": "Alex", "age": 25}}} \ No newline at end of file diff --git a/run.py b/run.py index 861e3d8..9a704e8 100644 --- a/run.py +++ b/run.py @@ -24,6 +24,7 @@ def post(post_id): @app.route("/api", methods=["GET", "POST"]) def api(): + return "", 204 diff --git a/system_module/db.py b/system_module/db.py index 9ea6472..86f5fea 100644 --- a/system_module/db.py +++ b/system_module/db.py @@ -1,7 +1,32 @@ -# Образец для расширения! +from tinydb import TinyDB, Query +import os +import json -from tinydb import TinyDB - -db = TinyDB("db.json") - -db.insert({"name": "Alex", "age": 25}) \ No newline at end of file +class DB: + def __init__(self): + db_path = "datas" + if not os.path.exists(db_path): + os.makedirs(os.path.dirname(db_path), exist_ok=True) + json.dump({}, open(db_path+"/db.json", "w", encoding="utf-8")) + self.db = TinyDB(db_path+"/db.json") + self.File = Query() + + def add(self, data_add): + self.db.insert(data_add) + + def get_all(self): + return self.db.all() + + def get_search(self, ratings, tags): + results = self.db.search( + self.File.rating.one_of(self.ratings) & + self.File.tags.any(self.tags) + ) + return results + + def get_unknow(self): + results = self.db.search(self.File.tags == []) + return results + + def edit_data(self, id_file, edit_data): + self.db.update(self.edit_data, self.File.md5 == self.id_file) \ No newline at end of file