Compare commits

...

4 commits

Author SHA1 Message Date
Eugene Burmakin
43bc8c444c Fix name fetcher 2025-07-12 17:57:22 +02:00
Eugene Burmakin
6b96e1f0be Revert specs 2025-07-12 17:21:53 +02:00
Eugene Burmakin
0dff80e12b Fix some tests 2025-07-12 13:43:15 +02:00
Eugene Burmakin
58a7972976 Fix bulk name fetching job queue 2025-07-12 11:30:51 +02:00
10 changed files with 31 additions and 18 deletions

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
class AreaVisitsCalculatingJob < ApplicationJob
queue_as :default
queue_as :visit_suggesting
sidekiq_options retry: false
def perform(user_id)

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
class AreaVisitsCalculationSchedulingJob < ApplicationJob
queue_as :default
queue_as :visit_suggesting
sidekiq_options retry: false
def perform

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
class Places::BulkNameFetchingJob < ApplicationJob
queue_as :default
queue_as :places
def perform
Place.where(name: Place::DEFAULT_NAME).find_each do |place|

View file

@ -92,6 +92,9 @@ class Point < ApplicationRecord
end
def country_name
# We have a country column in the database,
# but we also have a country_id column.
# TODO: rename country column to country_name
self.country&.name || read_attribute(:country) || ''
end

View file

@ -15,16 +15,18 @@ module Places
return if properties.blank?
ActiveRecord::Base.transaction do
@place.name = properties['name']
@place.city = properties['city']
@place.country = properties['country']
@place.name = properties['name'] if properties['name'].present?
@place.city = properties['city'] if properties['city'].present?
@place.country = properties['country'] if properties['country'].present?
@place.geodata = geodata.data if DawarichSettings.store_geodata?
@place.save!
@place
.visits
.where(name: Place::DEFAULT_NAME)
.update_all(name: properties['name'])
if properties['name'].present?
@place
.visits
.where(name: Place::DEFAULT_NAME)
.update_all(name: properties['name'])
end
@place
end

View file

@ -37,5 +37,5 @@ tracks_bulk_creating_job:
place_name_fetching_job:
cron: "30 0 * * *" # every day at 00:30
class: "Places::NameFetchingJob"
class: "Places::BulkNameFetchingJob"
queue: places

View file

@ -4,13 +4,13 @@ require 'rails_helper'
RSpec.describe AreaVisitsCalculationSchedulingJob, type: :job do
describe '#perform' do
let(:area) { create(:area) }
let(:user) { create(:user) }
let!(:user) { create(:user) }
let!(:area) { create(:area, user: user) }
it 'calls the AreaVisitsCalculationService' do
expect(AreaVisitsCalculatingJob).to receive(:perform_later).with(user.id).and_call_original
expect(AreaVisitsCalculatingJob).to receive(:perform_later).with(user.id)
described_class.new.perform
described_class.new.perform_now
end
end
end

View file

@ -20,7 +20,7 @@ RSpec.describe Places::BulkNameFetchingJob, type: :job do
it 'can be enqueued' do
expect { described_class.perform_later }.to have_enqueued_job(described_class)
.on_queue('default')
.on_queue('places')
end
end
end

View file

@ -40,8 +40,10 @@ RSpec.configure do |config|
config.rswag_dry_run = false
config.before(:suite) do
# Ensure Rails routes are loaded for Devise
Rails.application.reload_routes!
# DatabaseCleaner.strategy = :transaction
# DatabaseCleaner.clean_with(:truncation)
end
config.before do
@ -90,6 +92,12 @@ RSpec.configure do |config|
config.after(:suite) do
Rake::Task['rswag:generate'].invoke
end
# config.around(:each) do |example|
# DatabaseCleaner.cleaning do
# example.run
# end
# end
end
Shoulda::Matchers.configure do |config|

View file

@ -29,7 +29,7 @@ RSpec.describe PointSerializer do
'inrids' => point.inrids,
'in_regions' => point.in_regions,
'city' => point.city,
'country' => point.country,
'country' => point.read_attribute(:country),
'geodata' => point.geodata,
'course' => point.course,
'course_accuracy' => point.course_accuracy,