mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 01:01:39 -05:00
Rework the app version checking to be performed in the background and update docker compose file to use different directories for gems cache
This commit is contained in:
parent
609688f144
commit
d3f6d0da7b
10 changed files with 82 additions and 18 deletions
24
CHANGELOG.md
24
CHANGELOG.md
|
|
@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||
|
||||
- Importing Immich data on the Imports page now will trigger an attempt to write raw json file with the data from Immich to `tmp/imports/immich_raw_data_CURRENT_TIME_USER_EMAIL.json` file. This is useful to debug the problem with the import if it fails. #270
|
||||
|
||||
### Fixed
|
||||
|
||||
- New app version is now being checked every 6 hours instead of 1 day and the check is being performed in the background. #238
|
||||
|
||||
### Changed
|
||||
|
||||
- Hostname definition for Sidekiq healtcheck to solve #344. See the diff:
|
||||
|
|
@ -24,6 +28,26 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||
+ test: [ "CMD-SHELL", "bundle exec sidekiqmon processes | grep ${HOSTNAME}" ]
|
||||
```
|
||||
|
||||
- Renamed directories used by app and sidekiq containers for gems cache to fix #339:
|
||||
|
||||
```diff
|
||||
dawarich_app:
|
||||
image: freikin/dawarich:latest
|
||||
container_name: dawarich_sidekiq
|
||||
volumes:
|
||||
- - gem_cache:/usr/local/bundle/gems
|
||||
+ - gem_cache:/usr/local/bundle/gems_app
|
||||
|
||||
...
|
||||
|
||||
dawarich_sidekiq:
|
||||
image: freikin/dawarich:latest
|
||||
container_name: dawarich_sidekiq
|
||||
volumes:
|
||||
- - gem_cache:/usr/local/bundle/gems
|
||||
+ - gem_cache:/usr/local/bundle/gems_sidekiq
|
||||
```
|
||||
|
||||
# 0.15.10 - 2024-10-25
|
||||
|
||||
### Fixed
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
def year_timespan(year)
|
||||
start_at = Time.new(year).beginning_of_year.strftime('%Y-%m-%dT%H:%M')
|
||||
end_at = Time.new(year).end_of_year.strftime('%Y-%m-%dT%H:%M')
|
||||
start_at = DateTime.new(year).beginning_of_year.strftime('%Y-%m-%dT%H:%M')
|
||||
end_at = DateTime.new(year).end_of_year.strftime('%Y-%m-%dT%H:%M')
|
||||
|
||||
{ start_at:, end_at: }
|
||||
end
|
||||
|
|
@ -66,9 +66,7 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
def new_version_available?
|
||||
Rails.cache.fetch('dawarich/app-version-check', expires_in: 1.day) do
|
||||
CheckAppVersion.new.call
|
||||
end
|
||||
CheckAppVersion.new.call
|
||||
end
|
||||
|
||||
def app_version
|
||||
|
|
|
|||
11
app/jobs/app_version_checking_job.rb
Normal file
11
app/jobs/app_version_checking_job.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AppVersionCheckingJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform
|
||||
Rails.cache.delete(CheckAppVersion::VERSION_CACHE_KEY)
|
||||
|
||||
CheckAppVersion.new.call
|
||||
end
|
||||
end
|
||||
|
|
@ -1,18 +1,24 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CheckAppVersion
|
||||
VERSION_CACHE_KEY = 'dawarich/app-version-check'
|
||||
|
||||
def initialize
|
||||
@repo_url = 'https://api.github.com/repos/Freika/dawarich/tags'
|
||||
@app_version = File.read('.app_version').strip
|
||||
end
|
||||
|
||||
def call
|
||||
begin
|
||||
latest_version = JSON.parse(Net::HTTP.get(URI.parse(@repo_url)))[0]['name']
|
||||
rescue StandardError
|
||||
return false
|
||||
end
|
||||
|
||||
latest_version != @app_version
|
||||
rescue StandardError
|
||||
false
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def latest_version
|
||||
Rails.cache.fetch(VERSION_CACHE_KEY, expires_in: 6.hours) do
|
||||
JSON.parse(Net::HTTP.get(URI.parse(@repo_url)))[0]['name']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,13 +17,12 @@
|
|||
<%= link_to 'DaWarIch', root_path, class: 'btn btn-ghost normal-case text-xl'%>
|
||||
<div class="badge mx-4 <%= 'badge-outline' if new_version_available? %>">
|
||||
<a href="https://github.com/Freika/dawarich/releases/latest" target="_blank" class="inline-flex items-center">
|
||||
<span class="hidden sm:inline"><%= app_version %></span>
|
||||
<span class="ml-1 align-middle">!</span>
|
||||
|
||||
<% if new_version_available? %>
|
||||
<span class="tooltip tooltip-bottom" data-tip="New version available! Check out Github releases!">
|
||||
|
||||
<span class="hidden sm:inline"><%= app_version %> !</span>
|
||||
</span>
|
||||
<% else %>
|
||||
<span class="hidden sm:inline"><%= app_version %></span>
|
||||
<% end %>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Load the Rails application.
|
||||
require_relative "application"
|
||||
require_relative 'application'
|
||||
|
||||
# Initialize the Rails application.
|
||||
Rails.application.initialize!
|
||||
|
||||
# Clear the cache of the application version
|
||||
|
||||
Rails.cache.delete(CheckAppVersion::VERSION_CACHE_KEY)
|
||||
|
|
|
|||
|
|
@ -19,3 +19,8 @@ watcher_job:
|
|||
cron: "0 */1 * * *" # every 1 hour
|
||||
class: "Import::WatcherJob"
|
||||
queue: imports
|
||||
|
||||
app_version_checking_job:
|
||||
cron: "0 */6 * * *" # every 6 hours
|
||||
class: "AppVersionCheckingJob"
|
||||
queue: default
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ services:
|
|||
image: freikin/dawarich:latest
|
||||
container_name: dawarich_app
|
||||
volumes:
|
||||
- gem_cache:/usr/local/bundle/gems
|
||||
- gem_cache:/usr/local/bundle/gems_app
|
||||
- public:/var/app/public
|
||||
- watched:/var/app/tmp/imports/watched
|
||||
networks:
|
||||
|
|
@ -91,7 +91,7 @@ services:
|
|||
image: freikin/dawarich:latest
|
||||
container_name: dawarich_sidekiq
|
||||
volumes:
|
||||
- gem_cache:/usr/local/bundle/gems
|
||||
- gem_cache:/usr/local/bundle/gems_sidekiq
|
||||
- public:/var/app/public
|
||||
- watched:/var/app/tmp/imports/watched
|
||||
networks:
|
||||
|
|
|
|||
15
spec/jobs/app_version_checking_job_spec.rb
Normal file
15
spec/jobs/app_version_checking_job_spec.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AppVersionCheckingJob, type: :job do
|
||||
describe '#perform' do
|
||||
let(:job) { described_class.new }
|
||||
|
||||
it 'calls CheckAppVersion service' do
|
||||
expect(CheckAppVersion).to receive(:new).and_return(instance_double(CheckAppVersion, call: true))
|
||||
|
||||
job.perform
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue