Clear dynamic data and recreate clean role profiles.
(
db_path: Path = DB_PATH,
roles_path: Path = ROLES_FILE,
backup_dir: Path = BACKUP_DIR,
roles: Optional[Iterable[str]] = None,
)
| 227 | |
| 228 | |
| 229 | def full_reset( |
| 230 | db_path: Path = DB_PATH, |
| 231 | roles_path: Path = ROLES_FILE, |
| 232 | backup_dir: Path = BACKUP_DIR, |
| 233 | roles: Optional[Iterable[str]] = None, |
| 234 | ) -> Dict[str, Any]: |
| 235 | """Clear dynamic data and recreate clean role profiles.""" |
| 236 | backup_path = backup_database(db_path=db_path, backup_dir=backup_dir) |
| 237 | roles_meta = load_roles_meta(roles_path=roles_path) |
| 238 | |
| 239 | conn = get_connection(db_path=db_path) |
| 240 | try: |
| 241 | before_counts = get_table_counts(conn) |
| 242 | clear_tables(conn, ("behavior_logs", "papers", "task_status")) |
| 243 | seeded_profiles = reset_user_profiles(conn, roles_meta, roles=roles) |
| 244 | reset_sqlite_sequences(conn, ("profiles", "papers", "behavior_logs", "task_status")) |
| 245 | conn.commit() |
| 246 | after_counts = get_table_counts(conn) |
| 247 | finally: |
| 248 | conn.close() |
| 249 | |
| 250 | return { |
| 251 | "backup_path": str(backup_path), |
| 252 | "before_counts": before_counts, |
| 253 | "after_counts": after_counts, |
| 254 | "seeded_profiles": seeded_profiles, |
| 255 | } |
| 256 | |
| 257 | |
| 258 | def benchmark_reset( |
no test coverage detected