avoid update bus info clean cache

This commit is contained in:
邱博亞 2023-10-31 19:52:25 +08:00
parent b819715799
commit b8ce8fa24e
2 changed files with 12 additions and 1 deletions

View File

@ -2,6 +2,8 @@ module RulingBus
class Engine < ::Rails::Engine class Engine < ::Rails::Engine
initializer "ruling_bus" do initializer "ruling_bus" do
require File.expand_path('../../../app/models/ruling_bus_setting', __FILE__) 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? RulingBusSetting.create if RulingBusSetting.first.nil?
OrbitApp.registration "RulingBus", :type => "ModuleApp" do OrbitApp.registration "RulingBus", :type => "ModuleApp" do
module_label "ruling_bus.ruling_bus" module_label "ruling_bus.ruling_bus"
@ -9,6 +11,14 @@ module RulingBus
authorizable authorizable
categorizable categorizable
widget_methods ["widget"] 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 side_bar do
head_label_i18n 'ruling_bus.ruling_bus', icon_class: "fa fa-bus" head_label_i18n 'ruling_bus.ruling_bus', icon_class: "fa fa-bus"
available_for "users" available_for "users"

View File

@ -10,7 +10,7 @@
<div class="col-sm-6"> <div class="col-sm-6">
<div> <div>
<strong class="route_name">{{route_name}}:</strong> <strong class="route_name">{{route_name}}:</strong>
<span class="bus_time">{{time_to_arrive}}</span> <span class="bus_time"></span>
</div> </div>
</div> </div>
</div> </div>
@ -49,6 +49,7 @@
update_bus(ele); update_bus(ele);
},{{update_interval}}); },{{update_interval}});
} }
update_bus($('#{{update_id}}[data-list="bus_infos"]')[0]);
update_interval_bus($('#{{update_id}}[data-list="bus_infos"]')[0]); update_interval_bus($('#{{update_id}}[data-list="bus_infos"]')[0]);
</script> </script>
<style type="text/css"> <style type="text/css">