Spaces:
Running
Running
Update mtdna_backend.py
Browse files- mtdna_backend.py +6 -6
mtdna_backend.py
CHANGED
@@ -535,15 +535,15 @@ def hash_user_id(user_input):
|
|
535 |
# return {}
|
536 |
def load_user_usage():
|
537 |
try:
|
538 |
-
parent_id = get_or_create_drive_folder("mtDNA-Location-Classifier")
|
539 |
-
iterate3_id = get_or_create_drive_folder("iterate3", parent_id=parent_id)
|
540 |
|
541 |
-
found = find_drive_file("user_usage_log.json", parent_folder_id=iterate3_id)
|
542 |
if not found:
|
543 |
return {} # not found, start fresh
|
544 |
|
545 |
file_id = found[0]["id"]
|
546 |
-
content = download_drive_file_content(file_id)
|
547 |
return json.loads(content.strip()) if content.strip() else {}
|
548 |
|
549 |
except Exception as e:
|
@@ -573,8 +573,8 @@ def load_user_usage():
|
|
573 |
# print(f"❌ Failed to save user usage to Google Sheets: {e}")
|
574 |
def save_user_usage(usage_dict):
|
575 |
try:
|
576 |
-
parent_id = get_or_create_drive_folder("mtDNA-Location-Classifier")
|
577 |
-
iterate3_id = get_or_create_drive_folder("iterate3", parent_id=parent_id)
|
578 |
|
579 |
import tempfile
|
580 |
tmp_path = os.path.join(tempfile.gettempdir(), "user_usage_log.json")
|
|
|
535 |
# return {}
|
536 |
def load_user_usage():
|
537 |
try:
|
538 |
+
parent_id = pipeline.get_or_create_drive_folder("mtDNA-Location-Classifier")
|
539 |
+
iterate3_id = pipeline.get_or_create_drive_folder("iterate3", parent_id=parent_id)
|
540 |
|
541 |
+
found = pipeline.find_drive_file("user_usage_log.json", parent_folder_id=iterate3_id)
|
542 |
if not found:
|
543 |
return {} # not found, start fresh
|
544 |
|
545 |
file_id = found[0]["id"]
|
546 |
+
content = pipeline.download_drive_file_content(file_id)
|
547 |
return json.loads(content.strip()) if content.strip() else {}
|
548 |
|
549 |
except Exception as e:
|
|
|
573 |
# print(f"❌ Failed to save user usage to Google Sheets: {e}")
|
574 |
def save_user_usage(usage_dict):
|
575 |
try:
|
576 |
+
parent_id = pipeline.get_or_create_drive_folder("mtDNA-Location-Classifier")
|
577 |
+
iterate3_id = pipeline.get_or_create_drive_folder("iterate3", parent_id=parent_id)
|
578 |
|
579 |
import tempfile
|
580 |
tmp_path = os.path.join(tempfile.gettempdir(), "user_usage_log.json")
|