Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Jul 27, 2023
1 parent e73ec84 commit b922002
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/controllers/analytics/sparkline_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require 'csv'
module Analytics
class SparklineController < ApplicationController
Expand All @@ -15,7 +16,6 @@ def vega_specification

def vega_data
@scores = Score.all

end
end
end
12 changes: 6 additions & 6 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

class HomeController < ApplicationController
def show
@cases = @current_user.cases
@cases = @current_user.cases.not_archived

# copied from dropdown_contoller.rb
@most_recent_cases = lookup_most_recent_cases
end



private

def lookup_most_recent_cases
# Using joins/includes will not return the proper list in the
# correct order because rails refuses to include the
Expand Down Expand Up @@ -40,7 +39,8 @@ def lookup_most_recent_cases

# map to objects
most_recent_cases = Case.includes(:tries).where(id: [ case_ids ])
most_recent_cases = most_recent_cases.select { |kase| !kase.last_score.blank? }
most_recent_cases = most_recent_cases.sort_by { |x| case_ids.index x.id }
return most_recent_cases
most_recent_cases
end
end
2 changes: 2 additions & 0 deletions app/views/analytics/sparkline/vega_data.csv.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"date","state","positive","positiveIncrease"
<% @scores.each do |score| %><%= ::CSV.generate_line([score.created_at.to_date.to_fs(:number), score.case.case_name, 100, (score.score * 100).to_i]).html_safe %><% end %>
2 changes: 2 additions & 0 deletions app/views/analytics/sparkline/vega_data.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# frozen_string_literal: true

json.array! @scores, partial: 'event', as: :score
2 changes: 0 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,10 @@
get 'tries_visualization/:case_id/vega_data' => 'tries_visualization#vega_data', as: :tries_visualization_vega_data
resources :cases do
resource :visibility, only: [ :update ], module: :cases

end
get 'sparkline/vega_specification' => 'sparkline#vega_specification',
as: :sparkline_vega_specification
get 'sparkline/vega_data' => 'sparkline#vega_data', as: :sparkline_vega_data

end

namespace :admin do
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/api/v1/users_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class UsersControllerTest < ActionController::TestCase
body = response.parsed_body

# rubocop:disable Layout/LineLength
assert body['default_scorer_id'].include? "Does not exist"
assert body['default_scorer_id'].include? 'Does not exist'
# assert body['default_scorer_id'].include? I18n.t('activerecord.errors.models.user.attributes.default_scorer_id.existence')
# rubocop:enable Layout/LineLength

Expand Down

0 comments on commit b922002

Please sign in to comment.