Remove complex poll stats
For now we think showing them would be showing too much data and it would be a bit confusing. I've been tempted to just remove the view and keep the methods in the model in case they're used by other institutions using CONSUL. However, it's probably better to wait until we're asked to re-implement them, and in the meantime we don't maintain code nobody uses. The code wasn't that great to start with (I know it because I wrote it).
This commit is contained in:
@@ -182,126 +182,6 @@ describe Poll::Stats do
|
||||
|
||||
expect(stats.participants_by_geozone["Midgar"][:percentage]).to eq(33.333)
|
||||
end
|
||||
|
||||
describe "participants by gender and channel" do
|
||||
before do
|
||||
4.times do
|
||||
create :poll_voter, :from_web, poll: poll,
|
||||
user: create(:user, :level_two, gender: "female")
|
||||
end
|
||||
|
||||
3.times do
|
||||
create :poll_voter, :from_web, poll: poll,
|
||||
user: create(:user, :level_two, gender: "male")
|
||||
end
|
||||
|
||||
2.times do
|
||||
create :poll_voter, :from_booth, poll: poll,
|
||||
user: create(:user, :level_two, gender: "female")
|
||||
end
|
||||
|
||||
1.times do
|
||||
create :poll_voter, :from_booth, poll: poll,
|
||||
user: create(:user, :level_two, gender: "male")
|
||||
end
|
||||
end
|
||||
|
||||
it "calculates total participants" do
|
||||
expect(stats.total_female_web).to eq(4)
|
||||
expect(stats.total_male_web).to eq(3)
|
||||
expect(stats.total_female_booth).to eq(2)
|
||||
expect(stats.total_male_booth).to eq(1)
|
||||
end
|
||||
|
||||
it "calculates percentage relative to the participants for that gender" do
|
||||
expect(stats.female_web_percentage).to eq(66.667)
|
||||
expect(stats.female_booth_percentage).to eq(33.333)
|
||||
|
||||
expect(stats.male_web_percentage).to eq(75.0)
|
||||
expect(stats.male_booth_percentage).to eq(25.0)
|
||||
end
|
||||
end
|
||||
|
||||
describe "participants by age and channel" do
|
||||
before do
|
||||
4.times do
|
||||
create :poll_voter, :from_web, poll: poll,
|
||||
user: create(:user, :level_two, date_of_birth: 37.years.ago)
|
||||
end
|
||||
|
||||
3.times do
|
||||
create :poll_voter, :from_web, poll: poll,
|
||||
user: create(:user, :level_two, date_of_birth: 52.years.ago)
|
||||
end
|
||||
|
||||
2.times do
|
||||
create :poll_voter, :from_booth, poll: poll,
|
||||
user: create(:user, :level_two, date_of_birth: 37.years.ago)
|
||||
end
|
||||
|
||||
1.times do
|
||||
create :poll_voter, :from_booth, poll: poll,
|
||||
user: create(:user, :level_two, date_of_birth: 52.years.ago)
|
||||
end
|
||||
end
|
||||
|
||||
it "calculates the count of users by channel and age" do
|
||||
expect(stats.web_participants_by_age["35 - 39"][:count]).to eq(4)
|
||||
expect(stats.web_participants_by_age["50 - 54"][:count]).to eq(3)
|
||||
expect(stats.booth_participants_by_age["35 - 39"][:count]).to eq(2)
|
||||
expect(stats.booth_participants_by_age["50 - 54"][:count]).to eq(1)
|
||||
end
|
||||
|
||||
it "calculates percentage relative to the participants for that age" do
|
||||
expect(stats.web_participants_by_age["35 - 39"][:percentage]).to eq(66.667)
|
||||
expect(stats.booth_participants_by_age["35 - 39"][:percentage]).to eq(33.333)
|
||||
|
||||
expect(stats.web_participants_by_age["50 - 54"][:percentage]).to eq(75.0)
|
||||
expect(stats.booth_participants_by_age["50 - 54"][:percentage]).to eq(25.0)
|
||||
end
|
||||
end
|
||||
|
||||
describe "participants by geozone and channel" do
|
||||
before do
|
||||
atlantis = create(:geozone, name: "Atlantis")
|
||||
lemuria = create(:geozone, name: "Lemuria")
|
||||
|
||||
4.times do
|
||||
create :poll_voter, :from_booth, poll: poll,
|
||||
user: create(:user, :level_two, geozone: atlantis)
|
||||
end
|
||||
|
||||
3.times do
|
||||
create :poll_voter, :from_booth, poll: poll,
|
||||
user: create(:user, :level_two, geozone: lemuria)
|
||||
end
|
||||
|
||||
2.times do
|
||||
create :poll_voter, :from_web, poll: poll,
|
||||
user: create(:user, :level_two, geozone: atlantis)
|
||||
end
|
||||
|
||||
1.times do
|
||||
create :poll_voter, :from_web, poll: poll,
|
||||
user: create(:user, :level_two, geozone: lemuria)
|
||||
end
|
||||
end
|
||||
|
||||
it "calculates the count of users by channel and geozone" do
|
||||
expect(stats.booth_participants_by_geozone["Atlantis"][:count]).to eq(4)
|
||||
expect(stats.booth_participants_by_geozone["Lemuria"][:count]).to eq(3)
|
||||
expect(stats.web_participants_by_geozone["Atlantis"][:count]).to eq(2)
|
||||
expect(stats.web_participants_by_geozone["Lemuria"][:count]).to eq(1)
|
||||
end
|
||||
|
||||
it "calculates percentage relative to the participants for that geozone" do
|
||||
expect(stats.booth_participants_by_geozone["Atlantis"][:percentage]).to eq(66.667)
|
||||
expect(stats.web_participants_by_geozone["Atlantis"][:percentage]).to eq(33.333)
|
||||
|
||||
expect(stats.booth_participants_by_geozone["Lemuria"][:percentage]).to eq(75.0)
|
||||
expect(stats.web_participants_by_geozone["Lemuria"][:percentage]).to eq(25.0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#generate" do
|
||||
|
||||
Reference in New Issue
Block a user