diff --git a/app/controllers/feeds_controller.rb b/app/controllers/feeds_controller.rb index 704da55..4a633d5 100644 --- a/app/controllers/feeds_controller.rb +++ b/app/controllers/feeds_controller.rb @@ -43,8 +43,10 @@ class FeedsController < ApplicationController end 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? + insert_idx = feed_annc[:all_contents_for_feed][locale_sym].index{|aa| (aa["org_is_top"] < a["org_is_top"] rescue false) || ((aa["org_is_top"] == a["org_is_top"]) && (aa[feeds_time_field] <= time_field_value))} + if insert_idx.nil? + insert_idx = ((a["org_is_top"] == 1) ? 0 : -1) + end 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)) @@ -93,8 +95,10 @@ class FeedsController < ApplicationController 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? + insert_idx = feed_annc[:all_contents_for_feed][locale_sym].index{|aa| (aa["org_is_top"] < a["org_is_top"] rescue false) || ((aa["org_is_top"] == a["org_is_top"]) && (aa[feeds_time_field] <= time_field_value))} + if insert_idx.nil? + insert_idx = ((a["org_is_top"] == 1) ? 0 : -1) + end 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))