Implement Event Ratings

This commit is contained in:
shlok007 2016-09-22 20:06:46 -04:00 committed by Shlok Srivastava
parent 5be1ad52ee
commit 20f4853487
67 changed files with 1298 additions and 378 deletions

View file

@ -0,0 +1,17 @@
class CreateRatingCaches < ActiveRecord::Migration
def self.up
create_table :rating_caches do |t|
t.belongs_to :cacheable, polymorphic: true
t.float :avg, null: false
t.integer :qty, null: false
t.string :dimension
t.timestamps
end
add_index :rating_caches, [:cacheable_id, :cacheable_type]
end
def self.down
drop_table :rating_caches
end
end

View file

@ -0,0 +1,18 @@
class CreateRates < ActiveRecord::Migration
def self.up
create_table :rates do |t|
t.belongs_to :rater
t.belongs_to :rateable, polymorphic: true
t.float :stars, null: false
t.string :dimension
t.timestamps
end
add_index :rates, :rater_id
add_index :rates, [:rateable_id, :rateable_type]
end
def self.down
drop_table :rates
end
end

View file

@ -0,0 +1,14 @@
class CreateAverageCaches < ActiveRecord::Migration
def self.up
create_table :average_caches do |t|
t.belongs_to :rater
t.belongs_to :rateable, polymorphic: true
t.float :avg, null: false
t.timestamps
end
end
def self.down
drop_table :average_caches
end
end

View file

@ -0,0 +1,13 @@
class CreateOverallAverages < ActiveRecord::Migration
def self.up
create_table :overall_averages do |t|
t.belongs_to :rateable, polymorphic: true
t.float :overall_avg, null: false
t.timestamps
end
end
def self.down
drop_table :overall_averages
end
end

View file

@ -0,0 +1,12 @@
class CreateVotableFields < ActiveRecord::Migration
def change
create_table :votable_fields do |t|
t.string :title
t.string :votable_type
t.boolean :enabled, default: true
t.references :conference
t.timestamps null: false
end
end
end

View file

@ -0,0 +1,5 @@
class AddForAdminToVotableField < ActiveRecord::Migration
def change
add_column :votable_fields, :for_admin, :boolean, default: false
end
end

View file

@ -0,0 +1,5 @@
class AddStarsToVotableField < ActiveRecord::Migration
def change
add_column :votable_fields, :stars, :integer, default: 5
end
end

View file

@ -0,0 +1,5 @@
class AddRatingEnabledToProgram < ActiveRecord::Migration
def change
add_column :programs, :rating_enabled, :boolean, default: false
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170302145716) do
ActiveRecord::Schema.define(version: 20170405004359) do
create_table "ahoy_events", force: :cascade do |t|
t.uuid "visit_id", limit: 16
@ -31,6 +31,15 @@ ActiveRecord::Schema.define(version: 20170302145716) do
t.datetime "updated_at"
end
create_table "average_caches", force: :cascade do |t|
t.integer "rater_id"
t.integer "rateable_id"
t.string "rateable_type"
t.float "avg", null: false
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "campaigns", force: :cascade do |t|
t.integer "conference_id"
t.string "name"
@ -266,6 +275,14 @@ ActiveRecord::Schema.define(version: 20170302145716) do
t.datetime "updated_at"
end
create_table "overall_averages", force: :cascade do |t|
t.integer "rateable_id"
t.string "rateable_type"
t.float "overall_avg", null: false
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "payments", force: :cascade do |t|
t.string "last4"
t.integer "amount"
@ -290,6 +307,7 @@ ActiveRecord::Schema.define(version: 20170302145716) do
t.datetime "voting_end_date"
t.integer "selected_schedule_id"
t.integer "schedule_interval", default: 15, null: false
t.boolean "rating_enabled", default: false
end
add_index "programs", ["selected_schedule_id"], name: "index_programs_on_selected_schedule_id"
@ -321,6 +339,31 @@ ActiveRecord::Schema.define(version: 20170302145716) do
t.datetime "updated_at"
end
create_table "rates", force: :cascade do |t|
t.integer "rater_id"
t.integer "rateable_id"
t.string "rateable_type"
t.float "stars", null: false
t.string "dimension"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "rates", ["rateable_id", "rateable_type"], name: "index_rates_on_rateable_id_and_rateable_type"
add_index "rates", ["rater_id"], name: "index_rates_on_rater_id"
create_table "rating_caches", force: :cascade do |t|
t.integer "cacheable_id"
t.string "cacheable_type"
t.float "avg", null: false
t.integer "qty", null: false
t.string "dimension"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "rating_caches", ["cacheable_id", "cacheable_type"], name: "index_rating_caches_on_cacheable_id_and_cacheable_type"
create_table "registration_periods", force: :cascade do |t|
t.integer "conference_id"
t.date "start_date"
@ -583,6 +626,17 @@ ActiveRecord::Schema.define(version: 20170302145716) do
add_index "visits", ["user_id"], name: "index_visits_on_user_id"
create_table "votable_fields", force: :cascade do |t|
t.string "title"
t.string "votable_type"
t.boolean "enabled", default: true
t.integer "conference_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "for_admin", default: false
t.integer "stars", default: 5
end
create_table "votes", force: :cascade do |t|
t.integer "event_id"
t.integer "rating"