diff --git a/cdmm/app/controllers/cdmm_controller.rb b/cdmm/app/controllers/cdmm_controller.rb index 51d19c1..27b15ab 100644 --- a/cdmm/app/controllers/cdmm_controller.rb +++ b/cdmm/app/controllers/cdmm_controller.rb @@ -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") @@ -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 } diff --git a/cdmm/config/routes.rb b/cdmm/config/routes.rb index 7a13b97..a0b88e1 100644 --- a/cdmm/config/routes.rb +++ b/cdmm/config/routes.rb @@ -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.