Skip to content

Commit

Permalink
Merge pull request #17 from UWaterlooMSCI342/default_urgency
Browse files Browse the repository at this point in the history
Fixing sorting urgency and teams hierarchy
  • Loading branch information
cdefaz authored Feb 8, 2022
2 parents fd632ca + 76eeabc commit 2327eea
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
1 change: 0 additions & 1 deletion app/controllers/static_pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def get_teams
current_week = week_range(now.cwyear, now.cweek)
@teams = Team.all.sort_by{|team| team.find_priority_weighted(current_week[:start_date], current_week[:end_date])|| "other" }
@unsubmitted = {current_week: {}, previous_week: {}}
@priority = {current_week: {}, previous_week: {}}
@teams.each do |team|
@unsubmitted[:current_week][team.id] = team.users_not_submitted(team.current_feedback).map{|user| user.name}
@unsubmitted[:previous_week][team.id] = team.users_not_submitted(team.current_feedback(now - 7.days)).map{|user| user.name}
Expand Down
19 changes: 18 additions & 1 deletion app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ def self.generate_team_code(length = 6)

@@reverse_order_avg_rating = false

def week_range(cyear, cweek)
start_date = Date.commercial(cyear, cweek)
end_date = start_date.next_day(6)

start_date = Time.zone.local(start_date.year, start_date.month, start_date.day)
end_date = Time.zone.local(end_date.year, end_date.month, end_date.day)

{start_date: start_date.to_datetime.beginning_of_day,
end_date: end_date.to_datetime.end_of_day}
end

def self.order_by(field)
if field == 'team_name'
if @@reverse_order_avg_rating == false
Expand All @@ -142,7 +153,13 @@ def self.order_by(field)
return Team.order('team_name').reverse_order
end
else
return Team.order('team_name')
now = Time.zone.now.to_datetime
start_date = Date.commercial(now.cwyear, now.cweek)
end_date = start_date.next_day(6)
start_date = start_date.to_datetime.beginning_of_day
end_date = end_date.to_datetime.end_of_day
return Team.all.sort_by{|team| team.find_priority_weighted(start_date, end_date)|| "other" }
end
end

end
2 changes: 1 addition & 1 deletion app/views/static_pages/home.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<thead>
<tr>
<th></th>
<th>Urgency/Intervention Level</th>
<th><%= link_to 'Urgency/Intervention Level', root_path %></th>
<th>Average Rating (Out of 10)</th>
<th><%= link_to 'Team Name', root_path(order_by: 'team_name') %></th>
<th>Team Members</th>
Expand Down

0 comments on commit 2327eea

Please sign in to comment.