Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update user classification counts filtering by project if session time is false. do not return session time as key in response #36

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/serializers/user_classification_counts_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ def response_data(user_counts, show_project_contributions:, show_time_spent:)
end
counts_grouped_by_period.map { |period, totals| { period: }.merge(totals) }
else
user_counts
user_counts.map do |c|
period_data = {
period: c.period,
count: c.count
}
show_time_spent ? period_data.merge({ session_time: c.session_time }) : period_data
end
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
expect(response_body['data'][0]['count']).to eq(1)
end

it 'returns total_count and time_spent and breakdown of user classifications wher period is given' do
it 'returns total_count and time_spent and breakdown of user classifications where period is given' do
get :query, params: { id: classification_event.user_id, period: 'day', time_spent: true }
expect(response.status).to eq(200)
response_body = JSON.parse(response.body)
Expand All @@ -47,6 +47,13 @@
expect(response_body['project_contributions'].length).to eq(1)
expect(response_body['project_contributions'][0]['project_id']).to eq(classification_event.project_id)
end

it 'returns user project classification counts without session_time if time_spent is false' do
get :query, params: { id: classification_event.user_id, project_id: 1, period: 'day' }
expect(response.status).to eq(200)
response_body = JSON.parse(response.body)
expect(response_body['data'][0]).not_to have_key('session_time')
end
end

context 'zooniverse_admin' do
Expand Down