removed commented out non working migration code for now
This commit is contained in:
parent
74e0d03b8f
commit
d7f06b9e6e
1 changed files with 27 additions and 24 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
class NotificationMultiplePeople < ActiveRecord::Migration
|
class NotificationMultiplePeople < ActiveRecord::Migration
|
||||||
def self.up
|
def self.up
|
||||||
create_table :notification_actors do |t|
|
create_table :notification_actors do |t|
|
||||||
t.integer :notification_id
|
t.integer :notification_id
|
||||||
t.integer :person_id
|
t.integer :person_id
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
|
|
@ -10,36 +10,39 @@ class NotificationMultiplePeople < ActiveRecord::Migration
|
||||||
add_index :notification_actors, [:notification_id, :person_id] , :unique => true
|
add_index :notification_actors, [:notification_id, :person_id] , :unique => true
|
||||||
add_index :notification_actors, :person_id ## if i am not mistaken we don't need this one because we won't query person.notifications
|
add_index :notification_actors, :person_id ## if i am not mistaken we don't need this one because we won't query person.notifications
|
||||||
|
|
||||||
execute "INSERT INTO notification_actors (notification_id, person_id) " +
|
#execute "INSERT INTO notification_actors (notification_id, person_id) " +
|
||||||
" SELECT id , actor_id " +
|
#" SELECT id , actor_id " +
|
||||||
" FROM notifications"
|
#" FROM notifications"
|
||||||
|
|
||||||
|
|
||||||
|
##TODO in sql
|
||||||
|
## 1) set target type
|
||||||
|
## 2) update the target_id from the comment to comment.post_id
|
||||||
|
#execute "UPDATE notifications "+
|
||||||
|
#" SET target_id = comment.post_id, target_type = 'post' " +
|
||||||
|
#" FROM notifications " +
|
||||||
|
#" INNER JOIN comments " +
|
||||||
|
#" WHERE notifications.target_id = comments.id AND notifications.action = 'comment_on_post' "
|
||||||
|
|
||||||
|
|
||||||
#TODO in sql
|
|
||||||
# 1) set target type
|
|
||||||
# 2) update the target_id from the comment to comment.post_id
|
|
||||||
execute "UPDATE notifications "+
|
|
||||||
" SET target_id = comment.post_id, target_type = 'post' " +
|
|
||||||
" FROM notifications " +
|
|
||||||
" INNER JOIN comments " +
|
|
||||||
" WHERE notifications.target_id = comments.id "
|
|
||||||
|
|
||||||
|
|
||||||
#bump up target to status message id if comment_on_post, also_commented
|
##bump up target to status message id if comment_on_post, also_commented
|
||||||
['comment_on_post', 'also_commented'].each do |type|
|
#['comment_on_post', 'also_commented'].each do |type|
|
||||||
|
|
||||||
Notification.joins(:target).where(:action => "comment_on_post").update_all(:target => target)
|
#Notification.joins(:target).where(:action => "comment_on_post").update_all(:target => target)
|
||||||
|
|
||||||
|
|
||||||
Notification.where(:action => 'comment_on_post').all.each{|n|
|
#Notification.where(:action => 'comment_on_post').all.each{|n|
|
||||||
n.target_id => Comment.find(n.target_id).post}
|
#n.target_id => Comment.find(n.target_id).post}
|
||||||
|
|
||||||
#for each user
|
##for each user
|
||||||
all = Notification.where(:type => 'comment_on_post', :user => user).all
|
#all = Notification.where(:type => 'comment_on_post', :user => user).all
|
||||||
first = all.first
|
#first = all.first
|
||||||
all[1..all.length-1].each{ |a|
|
#all[1..all.length-1].each{ |a|
|
||||||
first << a.notification_actors
|
#first << a.notification_actors
|
||||||
a.delete
|
#a.delete
|
||||||
}
|
#}
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue