diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index c86d04ad5..fb79c7ae7 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -288,7 +288,6 @@ Lint/StringConversionInInterpolation:
- 'app/models/poll/final_recount.rb'
- 'app/models/poll/null_result.rb'
- 'app/models/poll/partial_result.rb'
- - 'app/models/poll/recount.rb'
- 'app/models/poll/white_result.rb'
# Offense count: 15
diff --git a/app/controllers/admin/poll/booth_assignments_controller.rb b/app/controllers/admin/poll/booth_assignments_controller.rb
index 4eb591d02..358f26a65 100644
--- a/app/controllers/admin/poll/booth_assignments_controller.rb
+++ b/app/controllers/admin/poll/booth_assignments_controller.rb
@@ -15,7 +15,7 @@ class Admin::Poll::BoothAssignmentsController < Admin::BaseController
end
def show
- @booth_assignment = @poll.booth_assignments.includes(:recounts, :final_recounts, :voters,
+ @booth_assignment = @poll.booth_assignments.includes(:final_recounts, :voters,
officer_assignments: [officer: [:user]]).find(params[:id])
@voters_by_date = @booth_assignment.voters.group_by {|v| v.created_at.to_date}
end
diff --git a/app/controllers/admin/poll/officer_assignments_controller.rb b/app/controllers/admin/poll/officer_assignments_controller.rb
index 07f206f92..1f2a7ca2c 100644
--- a/app/controllers/admin/poll/officer_assignments_controller.rb
+++ b/app/controllers/admin/poll/officer_assignments_controller.rb
@@ -18,7 +18,7 @@ class Admin::Poll::OfficerAssignmentsController < Admin::BaseController
@officer = ::Poll::Officer.includes(:user).find(officer_assignment_params[:officer_id])
@officer_assignments = ::Poll::OfficerAssignment.
joins(:booth_assignment).
- includes(:recount, :final_recounts, booth_assignment: :booth).
+ includes(:final_recounts, booth_assignment: :booth).
where("officer_id = ? AND poll_booth_assignments.poll_id = ?", @officer.id, @poll.id).
order(:date)
end
diff --git a/app/helpers/poll_recounts_helper.rb b/app/helpers/poll_recounts_helper.rb
index 60e3da6d7..95ea813e3 100644
--- a/app/helpers/poll_recounts_helper.rb
+++ b/app/helpers/poll_recounts_helper.rb
@@ -1,15 +1,7 @@
module PollRecountsHelper
- def recount_for_date(recounts, date)
- recounts.select {|r| r.date == date}.first
- end
-
- def booth_assignment_sum_recounts(ba)
- ba.recounts.any? ? ba.recounts.to_a.sum(&:count) : nil
- end
-
def booth_assignment_sum_final_recounts(ba)
ba.final_recounts.any? ? ba.final_recounts.to_a.sum(&:count) : nil
end
-end
\ No newline at end of file
+end
diff --git a/app/models/poll/booth_assignment.rb b/app/models/poll/booth_assignment.rb
index 0519fffa6..5ef9d687e 100644
--- a/app/models/poll/booth_assignment.rb
+++ b/app/models/poll/booth_assignment.rb
@@ -4,7 +4,6 @@ class Poll
belongs_to :poll
has_many :officer_assignments, class_name: "Poll::OfficerAssignment", dependent: :destroy
- has_many :recounts, class_name: "Poll::Recount", dependent: :destroy
has_many :final_recounts, class_name: "Poll::FinalRecount", dependent: :destroy
has_many :officers, through: :officer_assignments
has_many :voters
diff --git a/app/models/poll/officer_assignment.rb b/app/models/poll/officer_assignment.rb
index cd4f53266..1d7326500 100644
--- a/app/models/poll/officer_assignment.rb
+++ b/app/models/poll/officer_assignment.rb
@@ -2,7 +2,6 @@ class Poll
class OfficerAssignment < ActiveRecord::Base
belongs_to :officer
belongs_to :booth_assignment
- has_one :recount
has_many :final_recounts
has_many :partial_results
has_many :voters
diff --git a/app/models/poll/recount.rb b/app/models/poll/recount.rb
deleted file mode 100644
index 57ced61fb..000000000
--- a/app/models/poll/recount.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-class Poll
- class Recount < ActiveRecord::Base
- belongs_to :booth_assignment, class_name: "Poll::BoothAssignment"
- belongs_to :officer_assignment, class_name: "Poll::OfficerAssignment"
-
- validates :booth_assignment_id, presence: true
- validates :date, presence: true, uniqueness: {scope: :booth_assignment_id}
- validates :officer_assignment_id, presence: true, uniqueness: {scope: :booth_assignment_id}
- validates :count, presence: true, numericality: {only_integer: true}
-
- before_save :update_logs
-
- def update_logs
- if count_changed? && count_was.present?
- self.count_log += ":#{count_was.to_s}"
- self.officer_assignment_id_log += ":#{officer_assignment_id_was.to_s}"
- end
- end
- end
-end
\ No newline at end of file
diff --git a/app/views/admin/poll/booth_assignments/show.html.erb b/app/views/admin/poll/booth_assignments/show.html.erb
index 519b36202..5b3ca41ab 100644
--- a/app/views/admin/poll/booth_assignments/show.html.erb
+++ b/app/views/admin/poll/booth_assignments/show.html.erb
@@ -44,44 +44,30 @@
- <% if @booth_assignment.recounts.empty? %>
-
- <%= t("admin.poll_booth_assignments.show.no_recounts") %>
-
- <% else %>
-
<%= t("admin.poll_booth_assignments.show.recounts_list") %>
-
-
-
- | <%= t("admin.poll_booth_assignments.show.date") %> |
- <%= t("admin.poll_booth_assignments.show.count_by_officer") %> |
- <%= t("admin.poll_booth_assignments.show.count_final") %> |
- <%= t("admin.poll_booth_assignments.show.count_by_system") %> |
-
-
-
- <% (@poll.starts_at.to_date..@poll.ends_at.to_date).each do |voting_date| %>
- <% recount = recount_for_date(@booth_assignment.recounts, voting_date) %>
- <% final_recount = final_recount_for_date(@booth_assignment.final_recounts, voting_date) %>
- <% system_count = @voters_by_date[voting_date].present? ? @voters_by_date[voting_date].size : 0 %>
-
- | <%= l voting_date %> |
- <% if recount.present? %>
-
- <%= recount.count %> |
- <% else %>
- - |
- <% end %>
- <% if final_recount.present? %>
- <%= final_recount.count %> |
- <% else %>
- - |
- <% end %>
- <%= system_count %> |
-
- <% end %>
-
-
- <% end %>
+
<%= t("admin.poll_booth_assignments.show.recounts_list") %>
+
+
+
+ | <%= t("admin.poll_booth_assignments.show.date") %> |
+ <%= t("admin.poll_booth_assignments.show.count_final") %> |
+ <%= t("admin.poll_booth_assignments.show.count_by_system") %> |
+
+
+
+ <% (@poll.starts_at.to_date..@poll.ends_at.to_date).each do |voting_date| %>
+ <% final_recount = final_recount_for_date(@booth_assignment.final_recounts, voting_date) %>
+ <% system_count = @voters_by_date[voting_date].present? ? @voters_by_date[voting_date].size : 0 %>
+
+ | <%= l voting_date %> |
+ <% if final_recount.present? %>
+ <%= final_recount.count %> |
+ <% else %>
+ - |
+ <% end %>
+ <%= system_count %> |
+
+ <% end %>
+
+
diff --git a/app/views/admin/poll/officer_assignments/by_officer.html.erb b/app/views/admin/poll/officer_assignments/by_officer.html.erb
index 205692535..6e505040e 100644
--- a/app/views/admin/poll/officer_assignments/by_officer.html.erb
+++ b/app/views/admin/poll/officer_assignments/by_officer.html.erb
@@ -65,35 +65,6 @@
<% end %>
-<% voting_days_officer_assignments = @officer_assignments.select{|oa| oa.final == false} %>
-<% if voting_days_officer_assignments.any? %>
- <%= t("admin.poll_officer_assignments.by_officer.recounts") %>
-
-
-
- | <%= t("admin.poll_officer_assignments.by_officer.date") %> |
- <%= t("admin.poll_officer_assignments.by_officer.booth") %> |
- <%= t("admin.poll_officer_assignments.by_officer.recount") %> |
-
-
-
- <% voting_days_officer_assignments.each do |officer_assignment| %>
-
- | <%= l(officer_assignment.date.to_date) %> |
- <%= booth_name_with_location(officer_assignment.booth_assignment.booth) %> |
-
- <% if officer_assignment.recount.present? %>
- <%= officer_assignment.recount.count %>
- <% else %>
- -
- <% end %>
- |
-
- <% end %>
-
-
-<% end %>
-
<% final_officer_assignments = @officer_assignments.select{|oa| oa.final == true} %>
<% if final_officer_assignments.any? %>
<%= t("admin.poll_officer_assignments.by_officer.final_recounts") %>
diff --git a/app/views/admin/poll/recounts/index.html.erb b/app/views/admin/poll/recounts/index.html.erb
index a4b0c6125..159b4b120 100644
--- a/app/views/admin/poll/recounts/index.html.erb
+++ b/app/views/admin/poll/recounts/index.html.erb
@@ -17,7 +17,6 @@
<% @booth_assignments.each do |booth_assignment| %>
- <% recount = booth_assignment_sum_recounts(booth_assignment) %>
<% final_recount = booth_assignment_sum_final_recounts(booth_assignment) %>
<% system_count = booth_assignment.voters.size %>
diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml
index 685d6b517..69ffa296e 100644
--- a/config/locales/en/admin.yml
+++ b/config/locales/en/admin.yml
@@ -504,8 +504,6 @@ en:
remove_assignment: "Remove"
assignments: "Officing shifts in this poll"
no_assignments: "This user has no officing shifts in this poll."
- recounts: "Daily recounts"
- recount: "Daily recount (by officer)"
final_recounts: "Final recounts"
final_recount: "Final recount (by officer)"
poll_booth_assignments:
@@ -521,9 +519,7 @@ en:
no_officers: "There are no officers for this booth"
recounts: "Recounts"
recounts_list: "Recount list for this booth"
- no_recounts: "There are not daily recounts of this booth yet"
date: "Date"
- count_by_officer: "Daily recount (by officer)"
count_final: "Final recount (by officer)"
count_by_system: "Votes (automatic)"
index:
diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml
index ac1a6e116..51862f2e1 100644
--- a/config/locales/es/admin.yml
+++ b/config/locales/es/admin.yml
@@ -521,9 +521,7 @@ es:
no_officers: "No hay presidentes de mesa para esta urna"
recounts: "Recuentos"
recounts_list: "Lista de recuentos de esta urna"
- no_recounts: "No hay recuentos diarios de esta urna"
date: "Fecha"
- count_by_officer: "Recuento diario (presidente de mesa)"
count_final: "Recuento final (presidente de mesa)"
count_by_system: "Votos (automático)"
index:
diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb
index 9a55b8c00..69a3cf926 100644
--- a/db/dev_seeds.rb
+++ b/db/dev_seeds.rb
@@ -576,19 +576,6 @@ print "Creating Poll Officer Assignments"
end
end
-puts " ✅"
-print "Creating Poll Recounts" do
- (1..15).to_a.sample.times do |i|
- poll_officer.poll_officer.officer_assignments.all.sample(i).each do |officer_assignment|
- Poll::Recount.create(officer_assignment: officer_assignment,
- booth_assignment: officer_assignment.booth_assignment,
- date: officer_assignment.date,
- count: (1..5000).to_a.sample)
- end
- end
-
-end
-
puts " ✅"
print "Creating Poll Questions from Proposals"
diff --git a/db/migrate/20170719174326_remove_poll_recount.rb b/db/migrate/20170719174326_remove_poll_recount.rb
new file mode 100644
index 000000000..67720ff91
--- /dev/null
+++ b/db/migrate/20170719174326_remove_poll_recount.rb
@@ -0,0 +1,8 @@
+class RemovePollRecount < ActiveRecord::Migration
+ def change
+ remove_index :poll_recounts, column: [:booth_assignment_id]
+ remove_index :poll_recounts, column: [:officer_assignment_id]
+
+ drop_table :poll_recounts
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index de746c5e0..91a26adeb 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20170713110317) do
+ActiveRecord::Schema.define(version: 20170719174326) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -652,20 +652,6 @@ ActiveRecord::Schema.define(version: 20170713110317) do
add_index "poll_questions", ["proposal_id"], name: "index_poll_questions_on_proposal_id", using: :btree
add_index "poll_questions", ["tsv"], name: "index_poll_questions_on_tsv", using: :gin
- create_table "poll_recounts", force: :cascade do |t|
- t.integer "booth_assignment_id"
- t.integer "officer_assignment_id"
- t.integer "count"
- t.text "count_log", default: ""
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.date "date", null: false
- t.text "officer_assignment_id_log", default: ""
- end
-
- add_index "poll_recounts", ["booth_assignment_id"], name: "index_poll_recounts_on_booth_assignment_id", using: :btree
- add_index "poll_recounts", ["officer_assignment_id"], name: "index_poll_recounts_on_officer_assignment_id", using: :btree
-
create_table "poll_voters", force: :cascade do |t|
t.string "document_number"
t.string "document_type"
@@ -1055,8 +1041,6 @@ ActiveRecord::Schema.define(version: 20170713110317) do
add_foreign_key "poll_questions", "polls"
add_foreign_key "poll_questions", "proposals"
add_foreign_key "poll_questions", "users", column: "author_id"
- add_foreign_key "poll_recounts", "poll_booth_assignments", column: "booth_assignment_id"
- add_foreign_key "poll_recounts", "poll_officer_assignments", column: "officer_assignment_id"
add_foreign_key "poll_voters", "polls"
add_foreign_key "poll_white_results", "poll_booth_assignments", column: "booth_assignment_id"
add_foreign_key "poll_white_results", "poll_officer_assignments", column: "officer_assignment_id"
diff --git a/spec/factories.rb b/spec/factories.rb
index 7b7e24d97..24c0767d4 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -478,13 +478,6 @@ FactoryGirl.define do
end
end
- factory :poll_recount, class: 'Poll::Recount' do
- association :officer_assignment, factory: :poll_officer_assignment
- association :booth_assignment, factory: :poll_booth_assignment
- count (1..100).to_a.sample
- date (1.month.ago.to_datetime..1.month.from_now.to_datetime).to_a.sample
- end
-
factory :poll_final_recount, class: 'Poll::FinalRecount' do
association :officer_assignment, factory: [:poll_officer_assignment, :final]
association :booth_assignment, factory: :poll_booth_assignment
diff --git a/spec/features/admin/poll/booth_assigments_spec.rb b/spec/features/admin/poll/booth_assigments_spec.rb
index ea2291e91..bcc27310f 100644
--- a/spec/features/admin/poll/booth_assigments_spec.rb
+++ b/spec/features/admin/poll/booth_assigments_spec.rb
@@ -97,16 +97,6 @@ feature 'Admin booths assignments' do
officer_assignment_2 = create(:poll_officer_assignment, booth_assignment: booth_assignment, date: poll.ends_at)
final_officer_assignment = create(:poll_officer_assignment, :final, booth_assignment: booth_assignment, date: poll.ends_at)
- recount_1 = create(:poll_recount,
- booth_assignment: booth_assignment,
- officer_assignment: officer_assignment_1,
- date: officer_assignment_1.date,
- count: 33)
- recount_2 = create(:poll_recount,
- booth_assignment: booth_assignment,
- officer_assignment: officer_assignment_2,
- date: officer_assignment_2.date,
- count: 78)
final_recount = create(:poll_final_recount,
booth_assignment: booth_assignment,
officer_assignment: final_officer_assignment,
@@ -114,7 +104,6 @@ feature 'Admin booths assignments' do
count: 5678)
booth_assignment_2 = create(:poll_booth_assignment, poll: poll)
- other_recount = create(:poll_recount, booth_assignment: booth_assignment_2, count: 100)
visit admin_poll_path(poll)
click_link 'Booths (2)'
@@ -123,57 +112,9 @@ feature 'Admin booths assignments' do
click_link 'Recounts'
within('#recounts_list') do
- expect(page).to_not have_content other_recount.count
-
- within("#recounting_#{recount_1.date.strftime('%Y%m%d')}") do
- expect(page).to have_content recount_1.count
- end
-
- within("#recounting_#{recount_2.date.strftime('%Y%m%d')}") do
- expect(page).to have_content recount_2.count
- end
-
within("#recounting_#{final_recount.date.strftime('%Y%m%d')}") do
expect(page).to have_content final_recount.count
end
-
- end
- end
-
- scenario 'Marks recount values with count-errors' do
- poll = create(:poll)
- booth = create(:poll_booth)
- booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
- today = Date.current
- officer_assignment = create(:poll_officer_assignment, booth_assignment: booth_assignment, date: today)
-
- recount = create(:poll_recount,
- booth_assignment: booth_assignment,
- officer_assignment: officer_assignment,
- date: officer_assignment.date,
- count: 1)
-
- visit admin_poll_booth_assignment_path(poll, booth_assignment)
- click_link 'Recounts'
-
- within('#recounts_list') do
- expect(page).to have_css("#recounting_#{recount.date.strftime('%Y%m%d')} td.count-error")
- within("#recounting_#{recount.date.strftime('%Y%m%d')}") do
- expect(page).to have_content recount.count
- expect(page).to have_content 0
- end
- end
-
- create(:poll_voter, :valid_document, poll: poll, booth_assignment: booth_assignment)
-
- visit admin_poll_booth_assignment_path(poll, booth_assignment)
- click_link 'Recounts'
-
- within('#recounts_list') do
- expect(page).to_not have_css('.count-error')
- within("#recounting_#{recount.date.strftime('%Y%m%d')}") do
- expect(page).to have_content(recount.count)
- end
end
end
diff --git a/spec/features/admin/poll/officer_assignments_spec.rb b/spec/features/admin/poll/officer_assignments_spec.rb
index 6cbe43d14..08cbd3f99 100644
--- a/spec/features/admin/poll/officer_assignments_spec.rb
+++ b/spec/features/admin/poll/officer_assignments_spec.rb
@@ -70,28 +70,22 @@ feature 'Admin officer assignments in poll' do
booth_assignment = create(:poll_booth_assignment)
poll = booth_assignment.poll
officer = create(:poll_officer)
- officer_assignment = create(:poll_officer_assignment,
- booth_assignment: booth_assignment,
- officer: officer,
- date: poll.starts_at)
+ create(:poll_officer_assignment,
+ booth_assignment: booth_assignment,
+ officer: officer,
+ date: poll.starts_at)
final_officer_assignment = create(:poll_officer_assignment, :final,
booth_assignment: booth_assignment,
officer: officer,
date: poll.ends_at + 1.day)
- recount = create(:poll_recount,
- booth_assignment: booth_assignment,
- officer_assignment: officer_assignment,
- date: officer_assignment.date,
- count: 77)
- final_recount = create(:poll_final_recount,
- booth_assignment: booth_assignment,
- officer_assignment: final_officer_assignment,
- date: poll.ends_at,
- count: 9876)
+ create(:poll_final_recount,
+ booth_assignment: booth_assignment,
+ officer_assignment: final_officer_assignment,
+ date: poll.ends_at,
+ count: 9876)
visit by_officer_admin_poll_officer_assignments_path(poll, officer_id: officer.id)
- within('#recount_list') { expect(page).to have_content('77') }
within('#final_recount_list') { expect(page).to have_content('9876') }
end
-end
\ No newline at end of file
+end
diff --git a/spec/models/poll/recount_spec.rb b/spec/models/poll/recount_spec.rb
deleted file mode 100644
index 2469354c2..000000000
--- a/spec/models/poll/recount_spec.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-require 'rails_helper'
-
-describe :recount do
-
- it "should update count_log if count changes" do
- recount = create(:poll_recount, count: 33)
-
- expect(recount.count_log).to eq("")
-
- recount.count = 33
- recount.save
- recount.count = 32
- recount.save
- recount.count = 34
- recount.save
-
- expect(recount.count_log).to eq(":33:32")
- end
-
- it "should update officer_assignment_id_log if count changes" do
- recount = create(:poll_recount, count: 33)
-
- expect(recount.count_log).to eq("")
-
- recount.count = 33
- poll_officer_assignment_1 = create(:poll_officer_assignment)
- recount.officer_assignment = poll_officer_assignment_1
- recount.save
-
- recount.count = 32
- poll_officer_assignment_2 = create(:poll_officer_assignment)
- recount.officer_assignment = poll_officer_assignment_2
- recount.save
-
- recount.count = 34
- poll_officer_assignment_3 = create(:poll_officer_assignment)
- recount.officer_assignment = poll_officer_assignment_3
- recount.save
-
- expect(recount.officer_assignment_id_log).to eq(":#{poll_officer_assignment_1.id}:#{poll_officer_assignment_2.id}")
- end
-
-end