Skip to content

Commit

Permalink
Ability to regenerate keywords from interface
Browse files Browse the repository at this point in the history
  • Loading branch information
CoralineAda committed Jun 19, 2024
1 parent bc3372b commit af858cf
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/survey_responses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
10 changes: 9 additions & 1 deletion app/views/survey_responses/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,23 @@
<%= link_to ">", survey_response_path(@next_response), class: "flip", id: "flip-right" %>
<% end %>

<h2>Keywords:</h2>
<% if @enqueued_at %>
<p>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.</p>
<% end %>

<% if @keywords.any? %>
<h2>Keywords:</h2>
<ul class="word-cloud">
<% @keywords.each do |keyword| %>
<li><%= keyword.name %></li>
<% end %>
</ul>
<% end %>

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

<h2>Derived categories of experiences:</h2>

<% if @categories.any? %>
Expand Down
7 changes: 5 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit af858cf

Please sign in to comment.