Skip to content
Extraits de code Groupes Projets
Valider f48d7a08 rédigé par zhitomirskiyi's avatar zhitomirskiyi
Parcourir les fichiers

wip

parent 59402928
Aucune requête de fusion associée trouvée
...@@ -7,7 +7,7 @@ class Notification < ActiveRecord::Base ...@@ -7,7 +7,7 @@ class Notification < ActiveRecord::Base
include Diaspora::Socketable include Diaspora::Socketable
belongs_to :recipient, :class_name => 'User' belongs_to :recipient, :class_name => 'User'
belongs_to :actor, :class_name => 'Person' has_many :actors, :class_name => 'Person', :through => :notification_actors
belongs_to :target, :polymorphic => true belongs_to :target, :polymorphic => true
def self.for(recipient, opts={}) def self.for(recipient, opts={})
......
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class NotificationActor < ActiveRecord::Base
belongs_to :notification
belongs_to :person
end
...@@ -29,6 +29,8 @@ class Person < ActiveRecord::Base ...@@ -29,6 +29,8 @@ class Person < ActiveRecord::Base
belongs_to :owner, :class_name => 'User' belongs_to :owner, :class_name => 'User'
has_many :notifications, :through => :notification_actors
before_destroy :remove_all_traces before_destroy :remove_all_traces
before_validation :clean_url before_validation :clean_url
......
class NotificationMultiplePeople < ActiveRecord::Migration
def self.up
create_table :notification_actors do |t|
t.integer :notifications_id
t.integer :person_id
t.timestamps
end
add_index :notification_actors, :notifications_id
add_index :notification_actors, [:notifications_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
execute "INSERT INTO notification_actors (id, person_id) " +
" SELECT id , actor_id " +
" FROM notifications"
end
def self.down
remove_index :notification_actors, :notifications_id
remove_index :notification_actors, [:notifications_id, :person_id]
remove_index :notification_actors, :person_id
drop_table :notification_actors
end
end
...@@ -293,6 +293,17 @@ ActiveRecord::Schema.define(:version => 20110127000953) do ...@@ -293,6 +293,17 @@ ActiveRecord::Schema.define(:version => 20110127000953) do
add_index "mongo_users", ["mongo_id"], :name => "index_mongo_users_on_mongo_id", :unique => true add_index "mongo_users", ["mongo_id"], :name => "index_mongo_users_on_mongo_id", :unique => true
create_table "notification_actors", :force => true do |t|
t.integer "notifications_id"
t.integer "person_id"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "notification_actors", ["notifications_id", "person_id"], :name => "index_notification_actors_on_notifications_id_and_person_id", :unique => true
add_index "notification_actors", ["notifications_id"], :name => "index_notification_actors_on_notifications_id"
add_index "notification_actors", ["person_id"], :name => "index_notification_actors_on_person_id"
create_table "notifications", :force => true do |t| create_table "notifications", :force => true do |t|
t.string "target_type" t.string "target_type"
t.integer "target_id" t.integer "target_id"
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter