Move cache jobs to initializers

This commit is contained in:
Eugene Burmakin
2025-06-01 15:31:53 +02:00
parent 06042708c8
commit 296e2c08fa
5 changed files with 25 additions and 13 deletions

View File

@@ -1 +1 @@
0.27.0
0.27.1

View File

@@ -4,7 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
# 0.27.0 - 2025-05-31
# 0.27.1 - 2025-06-01
## Fixed
- Cache jobs are now being scheduled correctly after app start.
- `countries.geojson` now have fixed alpha codes for France and Norway
# 0.27.0 - 2025-06-01
⚠️ This release includes a breaking change. ⚠️

View File

@@ -5,12 +5,3 @@ require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!
# Use an atomic operation to ensure one-time execution
if defined?(Rails::Server) && Rails.cache.write('cache_jobs_scheduled', true, unless_exist: true)
# Clear the cache
Cache::CleaningJob.perform_later
# Preheat the cache
Cache::PreheatingJob.perform_later
end

View File

@@ -0,0 +1,12 @@
# frozen_string_literal: true
Rails.application.config.after_initialize do
# Only run in server mode and ensure one-time execution with atomic write
if defined?(Rails::Server) && Rails.cache.write('cache_jobs_scheduled', true, unless_exist: true)
# Clear the cache
Cache::CleaningJob.perform_later
# Preheat the cache
Cache::PreheatingJob.perform_later
end
end

File diff suppressed because one or more lines are too long