Build 2602261523: live updates, invite cleanup and nuclear resync
This commit is contained in:
@@ -1991,6 +1991,29 @@ def clear_history() -> Dict[str, int]:
|
||||
return {"actions": actions, "snapshots": snapshots}
|
||||
|
||||
|
||||
def clear_user_objects_nuclear() -> Dict[str, int]:
|
||||
with _connect() as conn:
|
||||
# Preserve admin accounts, but remove invite/profile references so profile rows can be deleted safely.
|
||||
admin_reset = conn.execute(
|
||||
"""
|
||||
UPDATE users
|
||||
SET profile_id = NULL,
|
||||
invited_by_code = NULL,
|
||||
invited_at = NULL
|
||||
WHERE role = 'admin'
|
||||
"""
|
||||
).rowcount
|
||||
users = conn.execute("DELETE FROM users WHERE role != 'admin'").rowcount
|
||||
invites = conn.execute("DELETE FROM signup_invites").rowcount
|
||||
profiles = conn.execute("DELETE FROM user_profiles").rowcount
|
||||
return {
|
||||
"users": users,
|
||||
"invites": invites,
|
||||
"profiles": profiles,
|
||||
"adminsReset": admin_reset,
|
||||
}
|
||||
|
||||
|
||||
def cleanup_history(days: int) -> Dict[str, int]:
|
||||
if days <= 0:
|
||||
return {"actions": 0, "snapshots": 0}
|
||||
|
||||
Reference in New Issue
Block a user