-
Notifications
You must be signed in to change notification settings - Fork 603
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
Frontend changes for showing tabbed course overview stats #5064
Changes from 7 commits
02da8da
8c237a3
a0bb519
0c81559
23821ba
918faf0
8f2d6ca
9cc4b44
5670769
7dd7f26
f0e4e0b
c0b47bc
ae7d15d
f019e01
d8d7bf0
49b696b
f7c9833
c170b1c
82d042f
8aea637
1639e9f
34b8c98
6f58d37
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,9 +151,9 @@ def trained_percent | |
end | ||
|
||
def wikidata_stats | ||
stats ||= courses.joins(:course_stat).where.not(course_stats: nil).map do |course| | ||
stats ||= courses.joins(:course_stat).where.not(course_stats: nil).map { |course| | ||
course.course_stat.stats_hash['www.wikidata.org'] | ||
end | ||
}.compact | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think rubocop will complain about using braces for a multi-line block instead of do/end. You can still chain the do/end syntax with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ohkk, thanks. |
||
return { 'www.wikidata.org' => stats.inject { |a, b| a.merge(b) { |_, x, y| x + y } } } | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
describe 'Detailed course overview stats', type: :feature, js: true do | ||
let(:course) { create(:course, start: '2022-01-01', end: '2023-01-01') } | ||
before do | ||
create(:course_stats, course: course, | ||
stats_hash: { | ||
'www.wikidata.org': { | ||
'claims created': 35, | ||
'other updates': 2, | ||
'unknown': 6 | ||
}, | ||
'en.wikibooks.org-namespace-102': { | ||
'new_count': 5, | ||
'edited_count': 72 | ||
}, | ||
'en.wikipedia.org-namespace-0': { | ||
'new_count': 16, | ||
'edited_count': 103 | ||
} | ||
} | ||
) | ||
visit "/courses/#{course.slug}" | ||
end | ||
|
||
it 'shows tabs for all the course stats objects' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be a little better to condense this into one test example, because only loading the page once will be a little faster, and all these tasks together represent a typical user flow: first load the page and see the expected tabs, then look at the default tab's content and confirm that at least one of the expected stats is being displayed (eg, 35 claimed created), then click to the next tab (ideally identifying it by the rendered label rather than the |
||
expect(page.find('#tab-0')).to have_content('www.wikidata.org') | ||
expect(page.find('#tab-1')).to have_content('en.wikibooks.org - Cookbook') | ||
expect(page.find('#tab-2')).to have_content('en.wikipedia.org - Mainspace') | ||
end | ||
|
||
it 'shows cookbook stats on clicking the \'en.wikibooks.org - Cookbook\' tab' do | ||
page.find('#tab-1').click | ||
expect(page).to have_content('en.wikibooks.org - Cookbook') | ||
expect(page).to have_content('Articles Edited') | ||
end | ||
|
||
it 'shows wikidata overview stats on clicking the \'www.wikidata.org\' tab' do | ||
page.find('#tab-0').click | ||
expect(page).to have_content('www.wikidata.org') | ||
expect(page).to have_content('Claims') | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the user count needs to be in any namespace-specific stats.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't it give insight of how many students worked on particular tracked namespace?