Problem
Users currently have no way to start with a clean data state through the web UI or API. The only options are:
- Individual deletion via CRUD (tedious for bulk cleanup)
rake db:purge (command-line only, no UI)
nuke.sh scripts (tear down the entire Docker deployment — overkill)
- Admin restore (replaces DB with a backup, but not a "clean slate")
Current State
What exists:
- Individual project/analysis/datapoint delete via
DELETE /projects/:id, DELETE /analyses/:id, DELETE /data_points/:id
- Cascading
dependent: :destroy on Project→Analyses→DataPoints (with filesystem cleanup via background jobs)
- Admin page (
/admin) with: backup, restore, prune dead Resque workers, requeue failed jobs
- Mongoid's built-in
rake db:purge (drops all collections)
What's missing:
- No
DELETE /admin/projects or POST /admin/reset endpoint
- No "Delete All" or "Reset" button in the admin UI
- No rake task for selective cleanup (e.g., purge completed analyses only)
Proposed Implementation
API
Add POST /admin/reset endpoint that:
- Drops all collections in the database (equivalent to
db:purge)
- Cleans up filesystem artifacts under
/mnt/openstudio/server/assets/analyses/
- Returns confirmation of what was deleted
Optional: Add DELETE /admin/projects for project-only purge (less destructive).
Web UI
Add a "Reset All Data" button to server/app/views/admin/index.html.erb:
- Confirmation dialog: "This will permanently delete ALL projects, analyses, and datapoints. Are you sure?"
- Calls
POST /admin/reset via form submission
- Shows success/failure message
Rake Task
Add rake data:reset for command-line use (mirrors the API endpoint).
Files to Modify
server/app/controllers/admin_controller.rb (add reset action)
server/config/routes.rb (add route)
server/app/views/admin/index.html.erb (add reset button + confirmation)
server/lib/tasks/ (add rake task)
Safety Considerations
- Should require admin authentication (already in place for admin controller)
- Should log the reset action
- Consider adding a "soft reset" that only removes completed/failed analyses, not running ones
- Filesystem cleanup should be async (background job) to avoid blocking the request
Problem
Users currently have no way to start with a clean data state through the web UI or API. The only options are:
rake db:purge(command-line only, no UI)nuke.shscripts (tear down the entire Docker deployment — overkill)Current State
What exists:
DELETE /projects/:id,DELETE /analyses/:id,DELETE /data_points/:iddependent: :destroyon Project→Analyses→DataPoints (with filesystem cleanup via background jobs)/admin) with: backup, restore, prune dead Resque workers, requeue failed jobsrake db:purge(drops all collections)What's missing:
DELETE /admin/projectsorPOST /admin/resetendpointProposed Implementation
API
Add
POST /admin/resetendpoint that:db:purge)/mnt/openstudio/server/assets/analyses/Optional: Add
DELETE /admin/projectsfor project-only purge (less destructive).Web UI
Add a "Reset All Data" button to
server/app/views/admin/index.html.erb:POST /admin/resetvia form submissionRake Task
Add
rake data:resetfor command-line use (mirrors the API endpoint).Files to Modify
server/app/controllers/admin_controller.rb(addresetaction)server/config/routes.rb(add route)server/app/views/admin/index.html.erb(add reset button + confirmation)server/lib/tasks/(add rake task)Safety Considerations