removed migration
This commit is contained in:
@@ -204,50 +204,3 @@ def get_all_stats():
|
||||
"by_source": dict(by_source),
|
||||
"top_domains": top_domains,
|
||||
}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Migration
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def migrate_pending():
|
||||
"""One-time migration: import 'done' entries from pending_emails.json.
|
||||
|
||||
Converts old-style action names ("archived" -> "archive", etc.) and
|
||||
records them as user decisions in the history file. Safe to run
|
||||
multiple times (will create duplicates though, so run once only).
|
||||
"""
|
||||
if not PENDING_FILE.exists():
|
||||
print("No pending_emails.json found, nothing to migrate.")
|
||||
return 0
|
||||
|
||||
with open(PENDING_FILE, "r", encoding="utf-8") as f:
|
||||
pending = json.load(f)
|
||||
|
||||
# Map old action names to new ones
|
||||
action_map = {
|
||||
"archived": "archive",
|
||||
"kept": "keep",
|
||||
"deleted": "delete",
|
||||
}
|
||||
|
||||
migrated = 0
|
||||
for msg_id, data in pending.items():
|
||||
if data.get("status") != "done":
|
||||
continue
|
||||
old_action = data.get("action", "")
|
||||
action = action_map.get(old_action, old_action)
|
||||
if not action:
|
||||
continue
|
||||
|
||||
email_data = {
|
||||
"sender": data.get("sender", ""),
|
||||
"recipient": data.get("recipient", ""),
|
||||
"subject": data.get("subject", ""),
|
||||
"summary": data.get("summary", ""),
|
||||
}
|
||||
record_decision(email_data, action, source="user")
|
||||
migrated += 1
|
||||
|
||||
print(f"Migrated {migrated} decisions from pending_emails.json")
|
||||
return migrated
|
||||
|
||||
Reference in New Issue
Block a user