Add repair sitemap , termofuse , and OrbitWidget appear repeatly.

This commit is contained in:
BOHUNG 2020-03-11 17:04:24 +08:00
parent ea9bb6b3fe
commit 504e82073d
1 changed files with 13 additions and 0 deletions

View File

@ -40,6 +40,19 @@ class Admin::PatchfilesController < OrbitAdminController
end end
end end
end end
keys = OrbitWidget.all.map{|w| w.key}.uniq
keep_ids = []
keys.each do |key|
keep_ids << OrbitWidget.where(:key=>key).desc(:id).first.id
end
orbit_widgets = OrbitWidget.all.to_a
orbit_widgets.each{|w| w.destroy if(!keep_ids.include? w.id)}
home_page = Page.where(:url=>'/').asc(:id).first
check_urls = ['/sitemap','/termofuse']
check_urls.each do |check_url|
check_url_ids = Page.where(:url=>check_url,:parent_page_id=>home_page.id).desc(:id).to_a
check_url_ids[1..-1].each{|uniq_page| uniq_page.destroy}
end
render :text => 'repair finish' render :text => 'repair finish'
end end
def index def index