Added cached_votes_total and cached_votes_down to Legislation Proposals
This commit is contained in:
@@ -80,10 +80,18 @@ class Legislation::Proposal < ActiveRecord::Base
|
||||
/\A#{Setting["proposal_code_prefix"]}-\d\d\d\d-\d\d-(\d*)\z/.match(terms)
|
||||
end
|
||||
|
||||
def total_votes
|
||||
def likes
|
||||
cached_votes_up
|
||||
end
|
||||
|
||||
def dislikes
|
||||
cached_votes_down
|
||||
end
|
||||
|
||||
def total_votes
|
||||
cached_votes_total
|
||||
end
|
||||
|
||||
def voters
|
||||
User.active.where(id: votes_for.voters)
|
||||
end
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class AddCachedVotesToLegislationProposals < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :legislation_proposals, :cached_votes_total, :integer, default: 0
|
||||
add_column :legislation_proposals, :cached_votes_down, :integer, default: 0
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20171020163240) do
|
||||
ActiveRecord::Schema.define(version: 20171025142440) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -528,6 +528,8 @@ ActiveRecord::Schema.define(version: 20171020163240) do
|
||||
t.integer "community_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "cached_votes_total", default: 0
|
||||
t.integer "cached_votes_down", default: 0
|
||||
end
|
||||
|
||||
add_index "legislation_proposals", ["legislation_process_id"], name: "index_legislation_proposals_on_legislation_process_id", using: :btree
|
||||
|
||||
Reference in New Issue
Block a user