This commit is contained in:
BoHung Chiu 2022-05-23 12:33:46 +08:00
parent ae6601ccd7
commit ffee522538
1 changed files with 15 additions and 0 deletions

View File

@ -38,6 +38,9 @@ class FeedsController < ApplicationController
locales.each do |locale| locales.each do |locale|
locale_sym = locale.to_sym locale_sym = locale.to_sym
time_field_value = Time.parse(a[feeds_time_field]) rescue a[feeds_time_field] time_field_value = Time.parse(a[feeds_time_field]) rescue a[feeds_time_field]
if feed_annc[:all_contents_for_feed][locale_sym].index{|aa| aa["id"] == a["id"]}
next
end
insert_idx = 0 insert_idx = 0
if time_field_value if time_field_value
insert_idx = feed_annc[:all_contents_for_feed][locale_sym].index{|aa| aa[feeds_time_field] <= time_field_value} insert_idx = feed_annc[:all_contents_for_feed][locale_sym].index{|aa| aa[feeds_time_field] <= time_field_value}
@ -77,14 +80,26 @@ class FeedsController < ApplicationController
a["category_id"] = category_id a["category_id"] = category_id
locales.each do |locale| locales.each do |locale|
locale_sym = locale.to_sym locale_sym = locale.to_sym
has_create = false
feed_annc[:all_contents_for_feed][locale_sym].each_with_index do |aa, i| feed_annc[:all_contents_for_feed][locale_sym].each_with_index do |aa, i|
if aa["id"] == a["id"] if aa["id"] == a["id"]
feed_annc.all_contents_for_feed_will_change! feed_annc.all_contents_for_feed_will_change!
feed_annc[:all_contents_for_feed][locale_sym][i] = feed_annc.process_tmp(a,locale,trans,site_root_url) feed_annc[:all_contents_for_feed][locale_sym][i] = feed_annc.process_tmp(a,locale,trans,site_root_url)
feed_data[channel_key_pluralize][i] = a feed_data[channel_key_pluralize][i] = a
has_create = true
break break
end end
end end
unless has_create
insert_idx = 0
if time_field_value
insert_idx = feed_annc[:all_contents_for_feed][locale_sym].index{|aa| aa[feeds_time_field] <= time_field_value}
insert_idx = 0 if insert_idx.nil?
end
feed_annc.all_contents_for_feed_will_change!
feed_annc[:all_contents_for_feed][locale_sym].insert(insert_idx, feed_annc.process_tmp(a,locale,trans,site_root_url))
feed_data[channel_key_pluralize].insert(insert_idx, a)
end
end end
if can_create_record if can_create_record
record = feeds_model.where(feeds_uid_field=>a["id"], :site_feed_id=>feed_id).first record = feeds_model.where(feeds_uid_field=>a["id"], :site_feed_id=>feed_id).first