diff --git a/app/queries/count_group_active_user_classifications.rb b/app/queries/count_group_active_user_classifications.rb index c25765d..27ccae3 100644 --- a/app/queries/count_group_active_user_classifications.rb +++ b/app/queries/count_group_active_user_classifications.rb @@ -23,7 +23,7 @@ def initial_scope(relation) end def select_clause - 'user_id, SUM(classification_count)::integer AS count' + 'user_id, SUM(classification_count)::integer AS count, SUM(total_session_time)::float AS session_time' end def relation(params) diff --git a/spec/queries/count_group_active_user_classifications_spec.rb b/spec/queries/count_group_active_user_classifications_spec.rb index 93b856e..fce64b6 100644 --- a/spec/queries/count_group_active_user_classifications_spec.rb +++ b/spec/queries/count_group_active_user_classifications_spec.rb @@ -24,7 +24,7 @@ describe 'select_clause' do it 'selects user_id and orders users by count' do counts = group_active_users_query.call(params) - expected_select_query = 'SELECT user_id, SUM(classification_count)::integer AS count FROM "daily_group_classification_count_and_time_per_user" ' + expected_select_query = 'SELECT user_id, SUM(classification_count)::integer AS count, SUM(total_session_time)::float AS session_time FROM "daily_group_classification_count_and_time_per_user" ' expected_select_query += 'GROUP BY "daily_group_classification_count_and_time_per_user"."user_id" ORDER BY count DESC' expect(counts.to_sql).to eq(expected_select_query) end