Skip to content

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

Description

@anchapin

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions