MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / full_reset

Function full_reset

scripts/clear_database.py:229–255  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

227
228
229def 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
258def benchmark_reset(

Callers 1

mainFunction · 0.85

Calls 8

backup_databaseFunction · 0.85
get_table_countsFunction · 0.85
clear_tablesFunction · 0.85
reset_user_profilesFunction · 0.85
reset_sqlite_sequencesFunction · 0.85
load_roles_metaFunction · 0.70
get_connectionFunction · 0.70
closeMethod · 0.45

Tested by

no test coverage detected