From 48eb55f621805e308ccd59b82d7fbdaee7f02733 Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Sat, 31 May 2025 21:58:50 +0200 Subject: [PATCH] Update changelog and add a spec --- CHANGELOG.md | 21 +++++++++++++++++++++ Gemfile | 2 +- config/cable.yml | 12 +++++------- config/initializers/solid_cache.rb | 11 ----------- spec/factories/imports.rb | 6 ++++++ spec/services/imports/destroy_spec.rb | 6 +++++- 6 files changed, 38 insertions(+), 20 deletions(-) delete mode 100644 config/initializers/solid_cache.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 00212687..bf2d811f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,27 @@ Moving to SolidQueue and SolidCache will require creating new SQLite databases, Background jobs interface is now available at `/jobs` page. +Please, update your `docker-compose.yml` and add the following: + +```diff + dawarich_app: + image: freikin/dawarich:latest + container_name: dawarich_app + volumes: + - dawarich_public:/var/app/public + - dawarich_watched:/var/app/tmp/imports/watched + - dawarich_storage:/var/app/storage ++ - dawarich_db_data:/dawarich_db_data +... + environment: + ... + DATABASE_NAME: dawarich_development + # SQLite database paths for secondary databases ++ QUEUE_DATABASE_PATH: /dawarich_db_data/dawarich_development_queue.sqlite3 ++ CACHE_DATABASE_PATH: /dawarich_db_data/dawarich_development_cache.sqlite3 ++ CABLE_DATABASE_PATH: /dawarich_db_data/dawarich_development_cable.sqlite3 +``` + ## Fixed diff --git a/Gemfile b/Gemfile index 7022ab66..cda663c3 100644 --- a/Gemfile +++ b/Gemfile @@ -23,7 +23,6 @@ gem 'lograge' gem 'mission_control-jobs' gem 'oj' gem 'pg' -gem 'sqlite3', '~> 2.6' gem 'prometheus_exporter' gem 'activerecord-postgis-adapter' gem 'puma' @@ -37,6 +36,7 @@ gem 'rswag-api' gem 'rswag-ui' gem 'sentry-ruby' gem 'sentry-rails' +gem 'sqlite3', '~> 2.6' gem 'stackprof' gem 'sidekiq' gem 'sidekiq-cron' diff --git a/config/cable.yml b/config/cable.yml index fd1a239f..7ca155ef 100644 --- a/config/cable.yml +++ b/config/cable.yml @@ -3,7 +3,7 @@ # not a terminal started via bin/rails console! Add "console" to any action or any ERB template view # to make the web console appear. -development: +default: &default adapter: solid_cable connects_to: database: @@ -11,13 +11,11 @@ development: polling_interval: 0.1.seconds message_retention: 1.day +development: + <<: *default + test: adapter: test production: - adapter: solid_cable - connects_to: - database: - writing: cable - polling_interval: 0.1.seconds - message_retention: 1.day + <<: *default diff --git a/config/initializers/solid_cache.rb b/config/initializers/solid_cache.rb deleted file mode 100644 index 15f78444..00000000 --- a/config/initializers/solid_cache.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -# Configure SolidCache -Rails.application.config.to_prepare do - # Only require the entries file as it seems the Entry class is defined there - begin - require 'solid_cache/store/entries' - rescue LoadError => e - Rails.logger.warn "Could not load SolidCache: #{e.message}" - end -end diff --git a/spec/factories/imports.rb b/spec/factories/imports.rb index 07dec894..76f6e0ac 100644 --- a/spec/factories/imports.rb +++ b/spec/factories/imports.rb @@ -5,5 +5,11 @@ FactoryBot.define do user name { 'owntracks_export.json' } source { Import.sources[:owntracks] } + + trait :with_points do + after(:create) do |import| + create_list(:point, 10, import:) + end + end end end diff --git a/spec/services/imports/destroy_spec.rb b/spec/services/imports/destroy_spec.rb index 5d7abc2c..cfb7fd95 100644 --- a/spec/services/imports/destroy_spec.rb +++ b/spec/services/imports/destroy_spec.rb @@ -5,13 +5,17 @@ require 'rails_helper' RSpec.describe Imports::Destroy do describe '#call' do let!(:user) { create(:user) } - let!(:import) { create(:import, user: user) } + let!(:import) { create(:import, :with_points, user: user) } let(:service) { described_class.new(user, import) } it 'destroys the import' do expect { service.call }.to change { Import.count }.by(-1) end + it 'destroys the points' do + expect { service.call }.to change { Point.count }.by(-import.points.count) + end + it 'enqueues a BulkStatsCalculatingJob' do expect(Stats::BulkCalculator).to receive(:new).with(user.id).and_return(double(call: nil))