Skip to content

Commit

Permalink
update user classification counts so that if show_time_spent is false…
Browse files Browse the repository at this point in the history
… when filtering user classification counts by project, session_time is not returned as a key (#35)
  • Loading branch information
yuenmichelle1 authored Oct 2, 2023
1 parent e7e823c commit 966d6d8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/serializers/user_classification_counts_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def response_data(user_counts, show_project_contributions:, show_time_spent:)
if show_project_contributions
counts_grouped_by_period = user_counts.group_by { |user_proj_class_count| user_proj_class_count[:period] }.transform_values do |counts_in_period|
total_in_period = { count: counts_in_period.sum(&:count) }
total_in_period[:session_time] = counts_in_period.sum(&:session_time) if show_time_spent
total_in_period
total_in_period_session_time = { session_time: counts_in_period.sum(&:session_time) } if show_time_spent
show_time_spent ? total_in_period.merge(total_in_period_session_time) : total_in_period
end
counts_grouped_by_period.map { |period, totals| { period: }.merge(totals) }
else
Expand Down

0 comments on commit 966d6d8

Please sign in to comment.