Fix channel title missing.

This commit is contained in:
BoHung Chiu 2022-05-24 17:17:26 +08:00
parent 4b55a647ba
commit d3a42b1132
2 changed files with 7 additions and 0 deletions

View File

@ -214,6 +214,8 @@ class Admin::FeedsController < OrbitAdminController
site_feed.feed_url = params[:feed][:url] site_feed.feed_url = params[:feed][:url]
module_app = ModuleApp.where(:key=>site_feed.channel_key).first module_app = ModuleApp.where(:key=>site_feed.channel_key).first
sync_fields_data = SiteFeed::ModuleAppSyncFields.map{|f| [f, module_app[f]] }.to_h 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.update(sync_fields_data)
site_feed.save site_feed.save
render :json => {"success" => true}.to_json render :json => {"success" => true}.to_json

View File

@ -14,6 +14,11 @@ Rails.application.routes.draw do
trans[locale]['more_plus'] = I18n.t("feed.more") trans[locale]['more_plus'] = I18n.t("feed.more")
end end
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 SiteFeedAnnc.where(:feed_id.nin=>SiteFeed.all.pluck(:id)).destroy
SiteFeed.each do |site_feed| SiteFeed.each do |site_feed|
site_feed.add_notify site_feed.add_notify