-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce new Homepage that Summarizes Your Progress (+ new nav?) (#684)
Brand new amazing awesome way better than before so needed and with a UX designed by an engineer ;-).
- Loading branch information
Showing
36 changed files
with
1,056 additions
and
127 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
require: rubocop-rails | ||
require: | ||
- rubocop-rails | ||
- rubocop-capybara | ||
|
||
|
||
AllCops: | ||
|
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 |
---|---|---|
|
@@ -93,3 +93,5 @@ group :test do | |
gem 'selenium-webdriver' | ||
gem 'webdrivers' | ||
end | ||
|
||
gem 'prophet-rb', '~> 0.4.2' |
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
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,18 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'csv' | ||
module Analytics | ||
class SparklineController < ApplicationController | ||
layout 'analytics' | ||
|
||
def show | ||
end | ||
|
||
def vega_specification | ||
end | ||
|
||
def vega_data | ||
@scores = Score.where(case_id: @current_user.cases.not_archived.select(:id)).includes([ :case ]) | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# frozen_string_literal: true | ||
|
||
class HomeController < ApplicationController | ||
# rubocop:disable Metrics/AbcSize | ||
def show | ||
# @cases = @current_user.cases.not_archived.includes([ :scores ]) | ||
@cases = @current_user.cases.not_archived | ||
|
||
# copied from dropdown_contoller.rb | ||
@most_recent_cases = lookup_most_recent_cases | ||
|
||
@most_recent_books = [] | ||
@lookup_for_books = {} | ||
@current_user.books_involved_with.order(:updated_at).each do |book| | ||
@most_recent_books << book | ||
judged_by_current_user = book.judgements.where(user: @current_user).count | ||
if judged_by_current_user.positive? && judged_by_current_user < book.query_doc_pairs.count | ||
@lookup_for_books[book] = book.query_doc_pairs.count - judged_by_current_user | ||
|
||
end | ||
break if 4 == @most_recent_books.count | ||
end | ||
|
||
candidate_cases = @cases.select { |kase| kase.scores.scored.count.positive? } | ||
@grouped_cases = candidate_cases.group_by { |kase| kase.case_name.split(':').first } | ||
@grouped_cases = @grouped_cases.select { |_key, value| value.count > 1 } | ||
end | ||
# rubocop:enable Metrics/AbcSize | ||
|
||
private | ||
|
||
# rubocop:disable Metrics/MethodLength | ||
def lookup_most_recent_cases | ||
# Using joins/includes will not return the proper list in the | ||
# correct order because rails refuses to include the | ||
# `case_metadata`.`last_viewed_at` column in the SELECT statement | ||
# which will then cause the ordering not to work properly. | ||
# So instead, we have this beauty! | ||
sql = " | ||
SELECT DISTINCT `cases`.`id`, `case_metadata`.`last_viewed_at` | ||
FROM `cases` | ||
LEFT OUTER JOIN `case_metadata` ON `case_metadata`.`case_id` = `cases`.`id` | ||
LEFT OUTER JOIN `teams_cases` ON `teams_cases`.`case_id` = `cases`.`id` | ||
LEFT OUTER JOIN `teams` ON `teams`.`id` = `teams_cases`.`team_id` | ||
LEFT OUTER JOIN `teams_members` ON `teams_members`.`team_id` = `teams`.`id` | ||
LEFT OUTER JOIN `users` ON `users`.`id` = `teams_members`.`member_id` | ||
WHERE (`teams_members`.`member_id` = #{current_user.id} OR `cases`.`owner_id` = #{current_user.id}) | ||
AND (`cases`.`archived` = false OR `cases`.`archived` IS NULL) | ||
ORDER BY `case_metadata`.`last_viewed_at` DESC, `cases`.`id` DESC | ||
LIMIT 4 | ||
" | ||
|
||
results = ActiveRecord::Base.connection.execute(sql) | ||
|
||
case_ids = [] | ||
results.each do |row| | ||
case_ids << row.first.to_i | ||
end | ||
|
||
# map to objects | ||
most_recent_cases = Case.includes([ :scorer, :scores ]).where(id: [ case_ids ]) | ||
most_recent_cases = most_recent_cases.select { |kase| kase.last_score.present? } | ||
# rubocop:enable | ||
most_recent_cases = most_recent_cases.sort_by(&:case_name) | ||
most_recent_cases | ||
end | ||
# rubocop:enable Metrics/MethodLength | ||
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,62 @@ | ||
# frozen_string_literal: true | ||
|
||
module HomeHelper | ||
def greeting | ||
greetings = [ | ||
'Good Day', | ||
'Hello', | ||
"How's your day", | ||
"How's your day going", | ||
'Good to see you', | ||
'So good to see you', | ||
'Hiya!', | ||
'Bonjour', | ||
'Hola!' | ||
] | ||
greetings.sample | ||
end | ||
|
||
# rubocop:disable Metrics/AbcSize | ||
# rubocop:disable Metrics/MethodLength | ||
def greeting2 | ||
current_time = DateTime.current.seconds_since_midnight | ||
midnight = DateTime.now.beginning_of_day.seconds_since_midnight | ||
noon = DateTime.now.middle_of_day.seconds_since_midnight | ||
five_pm = DateTime.now.change(:hour => 17 ).seconds_since_midnight | ||
eight_pm = DateTime.now.change(:hour => 20 ).seconds_since_midnight | ||
|
||
puts "DateTime.current #{DateTime.current}" | ||
puts "midnight: #{midnight}" | ||
puts "noon: #{noon}" | ||
puts "current_time: #{current_time}" | ||
|
||
if midnight.upto(noon).include?(current_time) | ||
greeting = 'Good Morning' | ||
elsif noon.upto(five_pm).include?(current_time) | ||
greeting = 'Good Afternoon' | ||
elsif five_pm.upto(eight_pm).include?(current_time) | ||
greeting = 'Good Evening' | ||
elsif eight_pm.upto(midnight + 1.day).include?(current_time) | ||
greeting = 'Good Night' | ||
end | ||
greeting | ||
end | ||
# rubocop:enable Metrics/AbcSize | ||
# rubocop:enable Metrics/MethodLength | ||
|
||
def book_title book | ||
if book.name.downcase.starts_with?('book') | ||
book.name | ||
else | ||
"Book #{book.name}" | ||
end | ||
end | ||
|
||
def case_title kase | ||
if kase.case_name.downcase.starts_with?('case') | ||
kase.case_name | ||
else | ||
"Case #{kase.case_name}" | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
json.case_id score.case_id | ||
json.date score.created_at | ||
json.y score.score | ||
json.symbol score.case.case_name |
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,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 %> |
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,3 @@ | ||
# frozen_string_literal: true | ||
|
||
json.array! @scores, partial: 'event', as: :score |
Oops, something went wrong.