-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from identity-research-lab/stats
Statistics/dashboard page
- Loading branch information
Showing
8 changed files
with
82 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
class QuestionsController < ApplicationController | ||
|
||
USERS = { ENV['GENERAL_ADMISSION_USERNAME'] => ENV['GENERAL_ADMISSION_PASSWORD'] } | ||
|
||
|
||
def show | ||
@question = Question.from(params[:id]) | ||
@responses = SurveyResponse.all.order(:created_at).reject{|sr| sr.read_attribute(@question.key).nil? } | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
class StatsController < ApplicationController | ||
|
||
def index | ||
|
||
sentiments = SurveyResponse.all.pluck(:sentiment) | ||
@pronoun_sentiment_positive = (sentiments.select{|sentiment| sentiment == "positive"}.count / sentiments.count.to_f * 100).to_i | ||
@pronoun_sentiment_neutral = (sentiments.select{|sentiment| sentiment == "neutral"}.count / sentiments.count.to_f * 100).to_i | ||
@pronoun_sentiment_negative = (sentiments.select{|sentiment| sentiment == "negative"}.count / sentiments.count.to_f * 100).to_i | ||
|
||
survey_response_count = SurveyResponse.count | ||
question_count = Question::QUESTIONS.count | ||
answer_count = survey_response_count * question_count | ||
persona_count = Persona.count | ||
identity_count = Identity.count | ||
code_count = Code.count | ||
category_count = Category.count | ||
keyword_count = Keyword.count | ||
|
||
@total_datapoints = survey_response_count + (question_count * survey_response_count) + identity_count + code_count + category_count + keyword_count + sentiments.compact.count | ||
|
||
@stats = { | ||
"Participant survey responses" => survey_response_count, | ||
"Survey questions" => question_count, | ||
"Survey answers" => answer_count, | ||
"Personas" => persona_count, | ||
"Self-expressed identities" => identity_count, | ||
"Codes" => code_count, | ||
"Derived categories" => category_count, | ||
"Derived Keywords" => keyword_count | ||
} | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<%- title "TWI-Web Statistics" %> | ||
|
||
<h1> | ||
Statistics. | ||
</h1> | ||
|
||
<h2><%= number_with_delimiter(@total_datapoints) %> total datapoints:</h2> | ||
<ul> | ||
<% @stats.each do |label, value| %> | ||
<li><%= label %>: <span class="highlight-green"><%= value.is_a?(String) ? value : number_with_delimiter(value) %></span></li> | ||
<% end %> | ||
</ul> | ||
|
||
<h2>Overall identity reflection sentiment:</h2> | ||
<ul> | ||
<li><span class="highlight-green"><%= @pronoun_sentiment_positive %>% positive</span></li> | ||
<li><span class="highlight-red"><%= @pronoun_sentiment_negative %>% negative</span></li> | ||
<li><span class="highlight-grey"><%= @pronoun_sentiment_neutral %>% neutral</span></li> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters