From e935c71efb9b5d4589bbe78314751ce3a84261f7 Mon Sep 17 00:00:00 2001 From: Marcos Ronaldo Date: Fri, 17 Jun 2016 12:17:28 -0300 Subject: [PATCH] fixes notificatio message and data migration --- app/helpers/action_tracker_helper.rb | 2 +- db/migrate/20160608123748_create_profile_followers_table.rb | 13 ++++++++++++- db/migrate/20160616143830_create_followers_for_social_circles.rb | 11 ----------- 3 files changed, 13 insertions(+), 13 deletions(-) delete mode 100644 db/migrate/20160616143830_create_followers_for_social_circles.rb diff --git a/app/helpers/action_tracker_helper.rb b/app/helpers/action_tracker_helper.rb index f8b0885..1da9210 100644 --- a/app/helpers/action_tracker_helper.rb +++ b/app/helpers/action_tracker_helper.rb @@ -15,7 +15,7 @@ module ActionTrackerHelper end def new_follower_description ta - n_('has followed 1 new profile:
%{name}', 'has followed %{num} new profiles:
%{name}', ta.get_follower_name.size).html_safe % { + n_('has 1 new follower:
%{name}', 'has %{num} new followers:
%{name}', ta.get_follower_name.size).html_safe % { num: ta.get_follower_name.size, name: safe_join(ta.collect_group_with_index(:follower_name) do |n,i| link_to image_tag(ta.get_follower_profile_custom_icon[i] || default_or_themed_icon("/images/icons-app/person-icon.png")), diff --git a/db/migrate/20160608123748_create_profile_followers_table.rb b/db/migrate/20160608123748_create_profile_followers_table.rb index e83e708..70e50d5 100644 --- a/db/migrate/20160608123748_create_profile_followers_table.rb +++ b/db/migrate/20160608123748_create_profile_followers_table.rb @@ -1,9 +1,20 @@ class CreateProfileFollowersTable < ActiveRecord::Migration - def change + def up create_table :profile_followers do |t| t.column :profile_id, :integer t.column :follower_id, :integer t.column :group, :string end + + add_index :profile_followers, [:profile_id, :follower_id], :name => "profile_followers_composite_key_index", :unique => true + + execute("INSERT INTO profile_followers(follower_id, profile_id, \"group\") SELECT f.person_id, f.friend_id, f.group FROM friendships as f") + execute("INSERT INTO profile_followers(follower_id, profile_id, \"group\") SELECT f.person_id, f.enterprise_id, 'favorites' FROM favorite_enterprise_people AS f") + execute("INSERT INTO profile_followers(follower_id, profile_id, \"group\") SELECT ra.accessor_id, ra.resource_id, 'member_of' FROM role_assignments as ra JOIN roles ON ra.role_id = roles.id WHERE roles.name IN ('Member','Moderator','Profile Administrator') ON CONFLICT DO NOTHING") + end + + def down + remove_index :profile_followers, :name => "profile_followers_composite_key_index" + drop_table :profile_followers end end diff --git a/db/migrate/20160616143830_create_followers_for_social_circles.rb b/db/migrate/20160616143830_create_followers_for_social_circles.rb deleted file mode 100644 index f22077c..0000000 --- a/db/migrate/20160616143830_create_followers_for_social_circles.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateFollowersForSocialCircles < ActiveRecord::Migration - def up - #OK amizades - #membros de comunidade - #OK fans de empreendimento - - execute("INSERT INTO profile_followers(follower_id, profile_id, group) SELECT friend_id, person_id, group FROM friendships") - execute("INSERT INTO profile_followers(follower_id, profile_id, group) SELECT f.person_id, f.enterprise_id, 'favorites' FROM favorite_enterprise_people AS f") - - end -end -- libgit2 0.21.2