diff --git a/app/services/geojson/import_parser.rb b/app/services/geojson/importer.rb similarity index 95% rename from app/services/geojson/import_parser.rb rename to app/services/geojson/importer.rb index 4e016d7c..c4cba58e 100644 --- a/app/services/geojson/import_parser.rb +++ b/app/services/geojson/importer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Geojson::ImportParser +class Geojson::Importer include Imports::Broadcaster include PointValidation diff --git a/app/services/google_maps/phone_takeout_parser.rb b/app/services/google_maps/phone_takeout_importer.rb similarity index 95% rename from app/services/google_maps/phone_takeout_parser.rb rename to app/services/google_maps/phone_takeout_importer.rb index 132ac14a..90f75f72 100644 --- a/app/services/google_maps/phone_takeout_parser.rb +++ b/app/services/google_maps/phone_takeout_importer.rb @@ -1,11 +1,8 @@ # frozen_string_literal: true -class GoogleMaps::PhoneTakeoutParser +class GoogleMaps::PhoneTakeoutImporter include Imports::Broadcaster - DOWNLOAD_TIMEOUT = 300 # 5 minutes timeout - MAX_RETRIES = 3 - attr_reader :import, :user_id def initialize(import, user_id) @@ -45,8 +42,6 @@ class GoogleMaps::PhoneTakeoutParser def parse_json # location-history.json could contain an array of data points # or an object with semanticSegments, rawSignals and rawArray - # I guess there are no easy ways with Google since these two are - # 3rd and 4th formats of their location data exports semantic_segments = [] raw_signals = [] raw_array = [] diff --git a/app/services/google_maps/semantic_history_parser.rb b/app/services/google_maps/semantic_history_importer.rb similarity index 98% rename from app/services/google_maps/semantic_history_parser.rb rename to app/services/google_maps/semantic_history_importer.rb index c9752151..ae6209b4 100644 --- a/app/services/google_maps/semantic_history_parser.rb +++ b/app/services/google_maps/semantic_history_importer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class GoogleMaps::SemanticHistoryParser +class GoogleMaps::SemanticHistoryImporter include Imports::Broadcaster BATCH_SIZE = 1000 diff --git a/app/services/imports/create.rb b/app/services/imports/create.rb index 4f2b22c8..f25d3e56 100644 --- a/app/services/imports/create.rb +++ b/app/services/imports/create.rb @@ -23,13 +23,13 @@ class Imports::Create def parser(source) # Bad classes naming by the way, they are not parsers, they are point creators case source - when 'google_semantic_history' then GoogleMaps::SemanticHistoryParser - when 'google_phone_takeout' then GoogleMaps::PhoneTakeoutParser + when 'google_semantic_history' then GoogleMaps::SemanticHistoryImporter + when 'google_phone_takeout' then GoogleMaps::PhoneTakeoutImporter when 'google_records' then GoogleMaps::RecordsStorageImporter when 'owntracks' then OwnTracks::Importer when 'gpx' then Gpx::TrackImporter - when 'geojson' then Geojson::ImportParser - when 'immich_api', 'photoprism_api' then Photos::ImportParser + when 'geojson' then Geojson::Importer + when 'immich_api', 'photoprism_api' then Photos::Importer end end diff --git a/app/services/photos/import_parser.rb b/app/services/photos/importer.rb similarity index 96% rename from app/services/photos/import_parser.rb rename to app/services/photos/importer.rb index d0022cfd..bd39b579 100644 --- a/app/services/photos/import_parser.rb +++ b/app/services/photos/importer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Photos::ImportParser +class Photos::Importer include Imports::Broadcaster include PointValidation attr_reader :import, :user_id diff --git a/spec/services/geojson/import_parser_spec.rb b/spec/services/geojson/importer_spec.rb similarity index 95% rename from spec/services/geojson/import_parser_spec.rb rename to spec/services/geojson/importer_spec.rb index ba5f76e9..7743030b 100644 --- a/spec/services/geojson/import_parser_spec.rb +++ b/spec/services/geojson/importer_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Geojson::ImportParser do +RSpec.describe Geojson::Importer do describe '#call' do subject(:service) { described_class.new(import, user.id).call } diff --git a/spec/services/google_maps/phone_takeout_parser_spec.rb b/spec/services/google_maps/phone_takeout_importer_spec.rb similarity index 97% rename from spec/services/google_maps/phone_takeout_parser_spec.rb rename to spec/services/google_maps/phone_takeout_importer_spec.rb index ac2db8b7..b48f9891 100644 --- a/spec/services/google_maps/phone_takeout_parser_spec.rb +++ b/spec/services/google_maps/phone_takeout_importer_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe GoogleMaps::PhoneTakeoutParser do +RSpec.describe GoogleMaps::PhoneTakeoutImporter do describe '#call' do subject(:parser) { described_class.new(import, user.id).call } diff --git a/spec/services/google_maps/semantic_history_parser_spec.rb b/spec/services/google_maps/semantic_history_importer_spec.rb similarity index 99% rename from spec/services/google_maps/semantic_history_parser_spec.rb rename to spec/services/google_maps/semantic_history_importer_spec.rb index 336df99c..44f47c85 100644 --- a/spec/services/google_maps/semantic_history_parser_spec.rb +++ b/spec/services/google_maps/semantic_history_importer_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe GoogleMaps::SemanticHistoryParser do +RSpec.describe GoogleMaps::SemanticHistoryImporter do describe '#call' do subject(:parser) { described_class.new(import, user.id).call } diff --git a/spec/services/imports/create_spec.rb b/spec/services/imports/create_spec.rb index 6483cf1f..69634149 100644 --- a/spec/services/imports/create_spec.rb +++ b/spec/services/imports/create_spec.rb @@ -17,8 +17,8 @@ RSpec.describe Imports::Create do content_type: 'application/json') end - it 'calls the GoogleMaps::SemanticHistoryParser' do - expect(GoogleMaps::SemanticHistoryParser).to \ + it 'calls the GoogleMaps::SemanticHistoryImporter' do + expect(GoogleMaps::SemanticHistoryImporter).to \ receive(:new).with(import, user.id).and_return(double(call: true)) service.call end @@ -31,8 +31,8 @@ RSpec.describe Imports::Create do context 'when source is google_phone_takeout' do let(:import) { create(:import, source: 'google_phone_takeout') } - it 'calls the GoogleMaps::PhoneTakeoutParser' do - expect(GoogleMaps::PhoneTakeoutParser).to \ + it 'calls the GoogleMaps::PhoneTakeoutImporter' do + expect(GoogleMaps::PhoneTakeoutImporter).to \ receive(:new).with(import, user.id).and_return(double(call: true)) service.call end @@ -129,8 +129,8 @@ RSpec.describe Imports::Create do context 'when source is geojson' do let(:import) { create(:import, source: 'geojson') } - it 'calls the Geojson::ImportParser' do - expect(Geojson::ImportParser).to \ + it 'calls the Geojson::Importer' do + expect(Geojson::Importer).to \ receive(:new).with(import, user.id).and_return(double(call: true)) service.call end @@ -139,8 +139,8 @@ RSpec.describe Imports::Create do context 'when source is immich_api' do let(:import) { create(:import, source: 'immich_api') } - it 'calls the Photos::ImportParser' do - expect(Photos::ImportParser).to \ + it 'calls the Photos::Importer' do + expect(Photos::Importer).to \ receive(:new).with(import, user.id).and_return(double(call: true)) service.call end @@ -149,8 +149,8 @@ RSpec.describe Imports::Create do context 'when source is photoprism_api' do let(:import) { create(:import, source: 'photoprism_api') } - it 'calls the Photos::ImportParser' do - expect(Photos::ImportParser).to \ + it 'calls the Photos::Importer' do + expect(Photos::Importer).to \ receive(:new).with(import, user.id).and_return(double(call: true)) service.call end diff --git a/spec/services/photos/import_parser_spec.rb b/spec/services/photos/importer_spec.rb similarity index 97% rename from spec/services/photos/import_parser_spec.rb rename to spec/services/photos/importer_spec.rb index 78cbd117..567898a3 100644 --- a/spec/services/photos/import_parser_spec.rb +++ b/spec/services/photos/importer_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Photos::ImportParser do +RSpec.describe Photos::Importer do describe '#call' do subject(:service) { described_class.new(import, user.id).call }