mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FEATURE: Create UserProfilerView.
This commit is contained in:
parent
afdb15f99f
commit
d30f454261
2 changed files with 20 additions and 0 deletions
5
app/models/user_profile_view.rb
Normal file
5
app/models/user_profile_view.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class UserProfileView < ActiveRecord::Base
|
||||
validates :user_profile_id, presence: true
|
||||
validates :viewed_at, presence: true
|
||||
validates :ip_address, presence: true
|
||||
end
|
15
db/migrate/20150914021445_create_user_profile_views.rb
Normal file
15
db/migrate/20150914021445_create_user_profile_views.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
class CreateUserProfileViews < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :user_profile_views do |t|
|
||||
t.integer :user_profile_id, null: false
|
||||
t.datetime :viewed_at, null: false
|
||||
t.inet :ip_address, null: false
|
||||
t.integer :user_id
|
||||
end
|
||||
|
||||
add_index :user_profile_views, :user_profile_id
|
||||
add_index :user_profile_views, :user_id
|
||||
add_index :user_profile_views, [:viewed_at, :ip_address, :user_profile_id], where: "user_id IS NULL", unique: true, name: 'unique_profile_view_ip'
|
||||
add_index :user_profile_views, [:viewed_at, :user_id, :user_profile_id], where: "user_id IS NOT NULL", unique: true, name: 'unique_profile_view_user'
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue