From d3a42b1132618432a09902b4b3b84b244d9c2b96 Mon Sep 17 00:00:00 2001 From: bohung Date: Tue, 24 May 2022 17:17:26 +0800 Subject: [PATCH] Fix channel title missing. --- app/controllers/admin/feeds_controller.rb | 2 ++ config/routes.rb | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/app/controllers/admin/feeds_controller.rb b/app/controllers/admin/feeds_controller.rb index c277c3d..bce6142 100644 --- a/app/controllers/admin/feeds_controller.rb +++ b/app/controllers/admin/feeds_controller.rb @@ -214,6 +214,8 @@ class Admin::FeedsController < OrbitAdminController site_feed.feed_url = params[:feed][:url] module_app = ModuleApp.where(:key=>site_feed.channel_key).first sync_fields_data = SiteFeed::ModuleAppSyncFields.map{|f| [f, module_app[f]] }.to_h + other_site_feed = SiteFeed.where(:remote_site_url=>site_feed.remote_site_url).first + site_feed.channel_title_translations = other_site_feed.channel_title_translations if other_site_feed site_feed.update(sync_fields_data) site_feed.save render :json => {"success" => true}.to_json diff --git a/config/routes.rb b/config/routes.rb index f9e39b7..9ae5bba 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -14,6 +14,11 @@ Rails.application.routes.draw do trans[locale]['more_plus'] = I18n.t("feed.more") end end + SiteFeed.all.order_by(:channel_title=>-1).to_a.group_by(&:remote_site_url).each do |url, site_feeds| + site_feed = site_feeds.first + channel_title_translations = site_feed.channel_title_translations + SiteFeed.where(:id.in=>site_feeds[1..-1].map{|sf| sf.id}).update_all(channel_title_translations.map{|l, s| ["channel_title.#{l}", s]}.to_h) + end SiteFeedAnnc.where(:feed_id.nin=>SiteFeed.all.pluck(:id)).destroy SiteFeed.each do |site_feed| site_feed.add_notify