mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
Compare commits
4 commits
cf50541be1
...
43bc8c444c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43bc8c444c | ||
|
|
6b96e1f0be | ||
|
|
0dff80e12b | ||
|
|
58a7972976 |
10 changed files with 31 additions and 18 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AreaVisitsCalculationSchedulingJob < ApplicationJob
|
||||
queue_as :default
|
||||
queue_as :visit_suggesting
|
||||
sidekiq_options retry: false
|
||||
|
||||
def perform
|
||||
|
|
|
|||
|
|
@ -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|
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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!
|
||||
|
||||
if properties['name'].present?
|
||||
@place
|
||||
.visits
|
||||
.where(name: Place::DEFAULT_NAME)
|
||||
.update_all(name: properties['name'])
|
||||
end
|
||||
|
||||
@place
|
||||
end
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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|
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue