Skip to content

Commit

Permalink
Merge pull request #17 from chonla/main
Browse files Browse the repository at this point in the history
feat: Add purging
  • Loading branch information
chonla authored Oct 24, 2024
2 parents 84c7dc8 + 3971b39 commit 4391c92
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cdmm/app/controllers/cdmm_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ class CdmmController < ApplicationController
# Purging
# draft form will be purged regularly

def purge
Evaluation.where(:form_status => :draft).destroy_all
render_empty
end

def index
form_key = generate_unique_form_key
default_table_title = Date.today.strftime("%B %d, %Y")
Expand Down Expand Up @@ -694,6 +699,12 @@ def generate_unique_form_key
end
end

def render_empty
respond_to do |format|
format.any { head :ok }
end
end

def render_internal_server_error
respond_to do |format|
format.html { render file: "#{Rails.root}/public/500.html", layout: false, status: :internal_server_error }
Expand Down
1 change: 1 addition & 0 deletions cdmm/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
get "cdmm" => "cdmm#index", as: :evaluation_index
post "cdmm" => "cdmm#save", as: :evaluation_save
get "cdmm/:form_key" => "cdmm#show", as: :evaluation_show
get "schedule/purge" => "cdmm#purge"

# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
# Can be used by load balancers and uptime monitors to verify that the app is live.
Expand Down

0 comments on commit 4391c92

Please sign in to comment.