Feedback Stats

<%= form_tag({}, {:method => :get}) do %>
<%= select_tag :product, options_for_select([['All', nil]].concat(DocumentationConstraint.product_with_parent_list), params[:product]), onchange: "this.form.submit();" %>
<%= date_field_tag :created_after, @created_after %>
<%= date_field_tag :created_before, @created_before %>
<%= link_to 'Reset', '/stats', class: "Vlt-btn Vlt-btn--tertiary Vlt-btn--app" %>   <%= submit_tag 'Update', class: 'Vlt-btn Vlt-btn--secondary Vlt-btn--app' %>
<% end %>

<%= @feedbacks.positive.count %>
Positive Feedbacks
<%= @feedbacks.neutral.count %>
Neutral Feedbacks
<%= @feedbacks.negative.count %>
Negative Feedbacks
<%= ((@feedbacks.positive.count.to_f / @feedbacks.count.to_f) * 100).round(1) %>%
Percent Positive

<%= column_chart( [ { name: 'Positive', color: '#32BA86', data: @feedbacks.positive.group_by_week('feedback_feedbacks.created_at').count }, { name: 'Neutral', color: '#e1e2e6', data: @feedbacks.neutral.group_by_week('feedback_feedbacks.created_at').count }, { name: 'Negative', color: '#ea5353', data: @feedbacks.negative.group_by_week('feedback_feedbacks.created_at').count }, ], stacked: true, defer: true ) %> <% all = @feedbacks.group_by_month('feedback_feedbacks.created_at').count positive = @feedbacks.positive.group_by_month('feedback_feedbacks.created_at').count neutral = @feedbacks.neutral.group_by_month('feedback_feedbacks.created_at').count negative = @feedbacks.negative.group_by_month('feedback_feedbacks.created_at').count all.each do |date, count| if count === 0 # Remove entries that had no feedbacks [all, positive, neutral, negative].each { |h| h.delete(date) } unless count == 0 else # Otherwise ensure that both positive and negative have values positive[date] = 0 unless positive[date] neutral[date] = 0 unless neutral[date] negative[date] = 0 unless negative[date] end # Convert values to percentages positive[date] = ((positive[date].to_f / count.to_f) * 100).round(1) neutral[date] = ((neutral[date].to_f / count.to_f) * 100).round(1) negative[date] = ((negative[date].to_f / count.to_f) * 100).round(1) end %>

Feedback split percent by month

<%= column_chart( [ { name: 'Positive', color: '#32BA86', data: positive }, { name: 'Neutral', color: '#e1e2e6', data: neutral }, { name: 'Negative', color: '#ea5353', data: negative }, ], stacked: true, defer: true ) %>

Worst Performing Content

<%= render 'performance_table', resources: Feedback::Resource.worst_performing.first(5) %>

Best Performing Content

<%= render 'performance_table', resources: Feedback::Resource.best_performing.first(5) %>