NatLabRockies / NatLabRockies/OpenStudio-server
Add 'Reset Data' endpoint and UI to purge all projects/analyses/datapoints
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 58
- Forks
- 27
- PR merge metrics
- No merged PRs in 30d
Description
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.shscripts (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: :destroyon 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/projectsorPOST /admin/resetendpoint - 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/resetvia 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(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
- 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading server/app/controllers/admin_controller.rb, server/config/routes.rb, and server/app/views/admin/index.html.erb, then compare the existing rake db:purge behavior. The work is done when the authenticated admin endpoint, confirmation UI, and server/lib/tasks/ rake task reset the specified data and filesystem artifacts, report the result, and log the action safely.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, ruby
- Domain
- api, backend, databases, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100