NatLabRockies / NatLabRockies/OpenStudio-server

Add 'Reset Data' endpoint and UI to purge all projects/analyses/datapoints

Open
#877 0 comments 0 reactions 0 assignees View on GitHub

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:

  1. Individual deletion via CRUD (tedious for bulk cleanup)
  2. rake db:purge (command-line only, no UI)
  3. nuke.sh scripts (tear down the entire Docker deployment — overkill)
  4. 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:

  1. Drops all collections in the database (equivalent to db:purge)
  2. Cleans up filesystem artifacts under /mnt/openstudio/server/assets/analyses/
  3. 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.