Implement Event Ratings
This commit is contained in:
parent
5be1ad52ee
commit
20f4853487
67 changed files with 1298 additions and 378 deletions
17
db/migrate/20160922205550_create_rating_caches.rb
Normal file
17
db/migrate/20160922205550_create_rating_caches.rb
Normal 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
|
||||
18
db/migrate/20160922205551_create_rates.rb
Normal file
18
db/migrate/20160922205551_create_rates.rb
Normal 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
|
||||
14
db/migrate/20160922205552_create_average_caches.rb
Normal file
14
db/migrate/20160922205552_create_average_caches.rb
Normal 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
|
||||
13
db/migrate/20160922205553_create_overall_averages.rb
Normal file
13
db/migrate/20160922205553_create_overall_averages.rb
Normal 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
|
||||
12
db/migrate/20170319144754_create_votable_fields.rb
Normal file
12
db/migrate/20170319144754_create_votable_fields.rb
Normal 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
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
class AddForAdminToVotableField < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :votable_fields, :for_admin, :boolean, default: false
|
||||
end
|
||||
end
|
||||
5
db/migrate/20170326084800_add_stars_to_votable_field.rb
Normal file
5
db/migrate/20170326084800_add_stars_to_votable_field.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class AddStarsToVotableField < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :votable_fields, :stars, :integer, default: 5
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
class AddRatingEnabledToProgram < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :programs, :rating_enabled, :boolean, default: false
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue