From b8ce8fa24eeede4606846e7bd4248c9ba96da9ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Tue, 31 Oct 2023 19:52:25 +0800 Subject: [PATCH] avoid update bus info clean cache --- lib/ruling_bus/engine.rb | 10 ++++++++++ modules/ruling_bus/_ruling_bus_widget1.html.erb | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/ruling_bus/engine.rb b/lib/ruling_bus/engine.rb index b4e158c..12683cf 100644 --- a/lib/ruling_bus/engine.rb +++ b/lib/ruling_bus/engine.rb @@ -2,6 +2,8 @@ module RulingBus class Engine < ::Rails::Engine initializer "ruling_bus" do require File.expand_path('../../../app/models/ruling_bus_setting', __FILE__) + require File.expand_path('../../../app/models/ruling_bus_info', __FILE__) + require File.expand_path('../../../app/models/ruling_bus_cache', __FILE__) RulingBusSetting.create if RulingBusSetting.first.nil? OrbitApp.registration "RulingBus", :type => "ModuleApp" do module_label "ruling_bus.ruling_bus" @@ -9,6 +11,14 @@ module RulingBus authorizable categorizable widget_methods ["widget"] + if File.basename($0) != 'rake' + begin + avoid_page_cache RulingBusInfo + avoid_page_cache RulingBusCache + rescue => e + puts ["avoid_page_cache", e.to_s] + end + end side_bar do head_label_i18n 'ruling_bus.ruling_bus', icon_class: "fa fa-bus" available_for "users" diff --git a/modules/ruling_bus/_ruling_bus_widget1.html.erb b/modules/ruling_bus/_ruling_bus_widget1.html.erb index 4ec8f60..5d55eef 100644 --- a/modules/ruling_bus/_ruling_bus_widget1.html.erb +++ b/modules/ruling_bus/_ruling_bus_widget1.html.erb @@ -10,7 +10,7 @@
{{route_name}}: - {{time_to_arrive}} +
@@ -49,6 +49,7 @@ update_bus(ele); },{{update_interval}}); } + update_bus($('#{{update_id}}[data-list="bus_infos"]')[0]); update_interval_bus($('#{{update_id}}[data-list="bus_infos"]')[0]);