From af858cf399ae2edc41f63adf66059e444522817f Mon Sep 17 00:00:00 2001 From: CoralineAda Date: Wed, 19 Jun 2024 15:13:31 -0500 Subject: [PATCH] Ability to regenerate keywords from interface --- README.md | 16 ++++++++++------ app/controllers/survey_responses_controller.rb | 7 +++++++ app/views/survey_responses/show.html.erb | 10 +++++++++- config/routes.rb | 7 +++++-- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7de2499..8fefd8b 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # tmi-web -tmi-web is a social science research tool for managing, analyzing, coding, and visualizing qualitative survey data on identities. It presents identity and experience in a network graph, encouraging tactile exploration of intersectional identities and facets of privilege and marginalization. +tmi-web is a social science research tool for managing, analyzing, coding, and visualizing qualitative survey data on identities. It presents identity and experience in a network graph, encouraging tactile exploration of intersectional identities and facets of privilege and marginalization. [![Hippocratic License HL3-CORE](https://img.shields.io/static/v1?label=Hippocratic%20License&message=HL3-CORE&labelColor=5e2751&color=bc8c3d)](https://firstdonoharm.dev/version/3/0/core.html) @@ -9,20 +9,24 @@ tmi-web is a social science research tool for managing, analyzing, coding, and v ### Start local sidekiq bundle exec sidekiq - + +### Clear sidekiq queue + + Sidekiq.redis(&:flushdb) + ### Backup production postgres database - heroku pg:backups:capture --app tmi-web + heroku pg:backups:capture --app tmi-web heroku pg:backups:download --app tmi-web - + ### Restore production postgres database to last db capture heroku pg:backups:restore --app tmi-web - + ### Load postgres database backup into local db pg_restore --verbose --clean --no-acl --no-owner -h localhost -U postgres -d tmi_web_development db/latest.dump - + ### Update neo4j schema rake neo4j:migrate diff --git a/app/controllers/survey_responses_controller.rb b/app/controllers/survey_responses_controller.rb index 821bc55..9f91197 100644 --- a/app/controllers/survey_responses_controller.rb +++ b/app/controllers/survey_responses_controller.rb @@ -22,6 +22,8 @@ def show @theme = params.permit(:theme)[:theme] @response = SurveyResponse.find(params[:id]) @total_responses = SurveyResponse.all.count + @enqueued_at = params[:enqueued_at] + @previous_response = SurveyResponse.where("created_at < ?", @response.created_at).order("created_at DESC").limit(1).first @next_response = SurveyResponse.where("created_at > ?", @response.created_at).order("created_at ASC").limit(1).first @@ -45,6 +47,11 @@ def update render :edit, status: :unprocessable_entity end end + + def enqueue_keywords + KeywordExtractorJob.perform_async(params[:survey_response_id]) + redirect_to( action: :show, id: params[:survey_response_id], params: {enqueued_at: Time.now.strftime("%I:%M:%S %P (%Z)")} ) + end private diff --git a/app/views/survey_responses/show.html.erb b/app/views/survey_responses/show.html.erb index 5ea9c35..7410e2b 100644 --- a/app/views/survey_responses/show.html.erb +++ b/app/views/survey_responses/show.html.erb @@ -9,8 +9,12 @@ <%= link_to ">", survey_response_path(@next_response), class: "flip", id: "flip-right" %> <% end %> +

Keywords:

+<% if @enqueued_at %> +

Keyword derivation was started at <%= @enqueued_at %>. Please allow up to 1 minute for the process to complete. You can reload this page to monitor progress.

+<% end %> + <% if @keywords.any? %> -

Keywords:

<% end %> +<% unless @enqueued_at %> + <%= button_to "Regenerate Keywords", survey_response_enqueue_keywords_path(@response, params: { enqueued: true }, method: :put ) %> +<% end %> +

Derived categories of experiences:

<% if @categories.any? %> diff --git a/config/routes.rb b/config/routes.rb index 26c5889..e90f10a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,13 +10,16 @@ root "survey_responses#index" - get "survey_responses/export", controller: "survey_responses", action: "export" get "about", controller: "static", action: "about" - resources :survey_responses + resources :survey_responses do + post "enqueue_keywords", action: "enqueue_keywords" + end + resources :codebooks do post "enqueue_categories", action: "enqueue_categories" end + resources :questions end