Commit 3236092ee26a9f49f1843361a0f277134e41e6c9
1 parent
2f048c18
Exists in
master
and in
1 other branch
Adding valid_record flag to vote and skip models
Showing
4 changed files
with
24 additions
and
1 deletions
Show diff stats
app/models/skip.rb
| @@ -3,4 +3,6 @@ class Skip < ActiveRecord::Base | @@ -3,4 +3,6 @@ class Skip < ActiveRecord::Base | ||
| 3 | belongs_to :question | 3 | belongs_to :question |
| 4 | belongs_to :prompt | 4 | belongs_to :prompt |
| 5 | has_one :appearance, :as => :answerable | 5 | has_one :appearance, :as => :answerable |
| 6 | + | ||
| 7 | + default_scope :conditions => {:valid_record => true} | ||
| 6 | end | 8 | end |
app/models/vote.rb
| @@ -18,6 +18,8 @@ class Vote < ActiveRecord::Base | @@ -18,6 +18,8 @@ class Vote < ActiveRecord::Base | ||
| 18 | named_scope :with_voter_ids, lambda { |*args| {:conditions => {:voter_id=> args.first }} } | 18 | named_scope :with_voter_ids, lambda { |*args| {:conditions => {:voter_id=> args.first }} } |
| 19 | named_scope :active, :include => :choice, :conditions => { 'choices.active' => true } | 19 | named_scope :active, :include => :choice, :conditions => { 'choices.active' => true } |
| 20 | 20 | ||
| 21 | + default_scope :conditions => {:valid_record => true} | ||
| 22 | + | ||
| 21 | serialize :tracking | 23 | serialize :tracking |
| 22 | 24 | ||
| 23 | after_create :update_winner_choice, :update_loser_choice | 25 | after_create :update_winner_choice, :update_loser_choice |
db/migrate/20100719030739_add_valid_flags_to_votes_and_skips.rb
0 → 100644
| @@ -0,0 +1,15 @@ | @@ -0,0 +1,15 @@ | ||
| 1 | +class AddValidFlagsToVotesAndSkips < ActiveRecord::Migration | ||
| 2 | + def self.up | ||
| 3 | + add_column :votes, :valid_record, :boolean, :default => true | ||
| 4 | + add_column :votes, :validity_information, :string | ||
| 5 | + add_column :skips, :valid_record, :boolean, :default => true | ||
| 6 | + add_column :skips, :validity_information, :string | ||
| 7 | + end | ||
| 8 | + | ||
| 9 | + def self.down | ||
| 10 | + remove_column :votes, :valid_record | ||
| 11 | + remove_column :votes, :validity_information | ||
| 12 | + remove_column :skips, :valid_record | ||
| 13 | + remove_column :skips, :validity_information | ||
| 14 | + end | ||
| 15 | +end |
db/schema.rb
| @@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
| 9 | # | 9 | # |
| 10 | # It's strongly recommended to check this file into your version control system. | 10 | # It's strongly recommended to check this file into your version control system. |
| 11 | 11 | ||
| 12 | -ActiveRecord::Schema.define(:version => 20100716121029) do | 12 | +ActiveRecord::Schema.define(:version => 20100719030739) do |
| 13 | 13 | ||
| 14 | create_table "appearances", :force => true do |t| | 14 | create_table "appearances", :force => true do |t| |
| 15 | t.integer "voter_id" | 15 | t.integer "voter_id" |
| @@ -179,6 +179,8 @@ ActiveRecord::Schema.define(:version => 20100716121029) do | @@ -179,6 +179,8 @@ ActiveRecord::Schema.define(:version => 20100716121029) do | ||
| 179 | t.datetime "updated_at" | 179 | t.datetime "updated_at" |
| 180 | t.string "skip_reason" | 180 | t.string "skip_reason" |
| 181 | t.string "missing_response_time_exp", :default => "" | 181 | t.string "missing_response_time_exp", :default => "" |
| 182 | + t.boolean "valid_record", :default => true | ||
| 183 | + t.string "validity_information" | ||
| 182 | end | 184 | end |
| 183 | 185 | ||
| 184 | add_index "skips", ["prompt_id"], :name => "index_skips_on_prompt_id" | 186 | add_index "skips", ["prompt_id"], :name => "index_skips_on_prompt_id" |
| @@ -224,6 +226,8 @@ ActiveRecord::Schema.define(:version => 20100716121029) do | @@ -224,6 +226,8 @@ ActiveRecord::Schema.define(:version => 20100716121029) do | ||
| 224 | t.integer "time_viewed" | 226 | t.integer "time_viewed" |
| 225 | t.integer "appearance_id" | 227 | t.integer "appearance_id" |
| 226 | t.string "missing_response_time_exp", :default => "" | 228 | t.string "missing_response_time_exp", :default => "" |
| 229 | + t.boolean "valid_record", :default => true | ||
| 230 | + t.string "validity_information" | ||
| 227 | end | 231 | end |
| 228 | 232 | ||
| 229 | add_index "votes", ["voter_id"], :name => "index_votes_on_voter_id" | 233 | add_index "votes", ["voter_id"], :name => "index_votes_on_voter_id" |