From b157190ef07159a600f6d8b8a08ab528ea09b4a9 Mon Sep 17 00:00:00 2001 From: Andy Zhao Date: Fri, 1 Mar 2019 16:42:38 -0500 Subject: [PATCH] Add missing data for org milestone notifications (#1939) * Remove duplicate line * Add missing json_data for org notifications --- app/labor/random_gif.rb | 1 - app/models/notification.rb | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/labor/random_gif.rb b/app/labor/random_gif.rb index d042455d4..fc1905483 100644 --- a/app/labor/random_gif.rb +++ b/app/labor/random_gif.rb @@ -6,7 +6,6 @@ class RandomGif "9PyhoXey73EpW" => { aspect_ratio: 0.753 }, "OcZp0maz6ALok" => { aspect_ratio: 1.000 }, "Is1O1TWV0LEJi" => { aspect_ratio: 0.565 }, - "xjZtu4qi1biIo" => { aspect_ratio: 1.0000 }, "lz24Z42jLcTa8" => { aspect_ratio: 0.776 }, "g9582DNuQppxC" => { aspect_ratio: 0.562 }, "l4HodBpDmoMA5p9bG" => { aspect_ratio: 1.000 }, diff --git a/app/models/notification.rb b/app/models/notification.rb index b332ceda4..c17e08ee3 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -258,11 +258,13 @@ class Notification < ApplicationRecord milestone_hash[:next_milestone] = next_milestone(milestone_hash) return unless should_send_milestone?(milestone_hash) + json_data = { article: article_data(milestone_hash[:article]), gif_id: RandomGif.new.random_id } + Notification.create!( user_id: milestone_hash[:article].user_id, notifiable_id: milestone_hash[:article].id, notifiable_type: "Article", - json_data: { article: article_data(milestone_hash[:article]), gif_id: RandomGif.new.random_id }, + json_data: json_data, action: "Milestone::#{milestone_hash[:type]}::#{milestone_hash[:next_milestone]}", ) if milestone_hash[:article].organization_id @@ -270,7 +272,7 @@ class Notification < ApplicationRecord organization_id: milestone_hash[:article].organization_id, notifiable_id: milestone_hash[:article].id, notifiable_type: "Article", - json_data: { article: article_data(milestone_hash[:article]) }, + json_data: json_data, action: "Milestone::#{milestone_hash[:type]}::#{milestone_hash[:next_milestone]}", ) end