Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/admin/book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def scoped_collection
FIO_FIELDS = %i[first_name last_name middle_name]

member_action :download, method: :post do
info = Books::Extract.call(id: params[:id])
info = Books::ExtractService.call(id: params[:id])

send_file info[:tempfile], type: 'application/octet-stream', filename: info[:filename]
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Authors::CounterCache
class Authors::CounterCacheCommand
include Callable

QUERY = <<~SQL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Authors::Parse
class Authors::ParseService
include Callable
extend Dry::Initializer

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Books::Extract
class Books::ExtractService
include Callable
extend Dry::Initializer

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Books::Links
class Books::LinksService
include Callable
extend Dry::Initializer

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Books::Parse
class Books::ParseService
include Callable
extend Dry::Initializer

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Folders::Parse
class Folders::ParseService
include Callable
extend Dry::Initializer

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Genres::CounterCache
class Genres::CounterCacheCommand
include Callable

QUERY = <<~SQL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Genres::Parse
class Genres::ParseService
include Callable
extend Dry::Initializer

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Keywords::CounterCache
class Keywords::CounterCacheCommand
include Callable

QUERY = <<~SQL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Keywords::Parse
class Keywords::ParseService
include Callable
extend Dry::Initializer

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Languages::CounterCache
class Languages::CounterCacheCommand
include Callable

QUERY = <<~SQL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Languages::Parse
class Languages::ParseService
include Callable
extend Dry::Initializer

Expand Down
6 changes: 3 additions & 3 deletions db/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
if (File.exist? Settings.app.sql_dump_path)
Seeds::SqlDumpLoad.call(filename: Settings.app.sql_dump_path)
Authors::CounterCache.call
Genres::CounterCache.call
Keywords::CounterCache.call
Authors::CounterCacheCommand.call
Genres::CounterCacheCommand.call
Keywords::CounterCacheCommand.call
else
Book.destroy_all
Seeds::GenreLoad.call(filename: 'db/seeds/genres.yml')
Expand Down
3 changes: 3 additions & 0 deletions lib/connector.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Connector
include Singleton
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions lib/setting.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Setting
include Singleton
extend Forwardable
def_delegators :@list, :[]=, :[]

def initialize
@list = {}
end
end
18 changes: 9 additions & 9 deletions lib/tasks/inpx.rake
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace :inpx do
puts title
folders = Parallel.map(Range.new(0, count - 1), in_processes: count) do |index|
start = Time.zone.now
folders = Folders::Parse.call(books: chunks[index])
folders = Folders::ParseService.call(books: chunks[index])
finish = Time.zone.now
puts format("Процесс %d: %0.2f сек", index, (finish - start))
folders.uniq
Expand All @@ -57,7 +57,7 @@ namespace :inpx do
puts title
Parallel.map(Range.new(0, count - 1), in_processes: count) do |index|
start = Time.zone.now
Books::Parse.call(books: chunks[index])
Books::ParseService.call(books: chunks[index])
finish = Time.zone.now
puts format("Процесс %d: %0.2f сек", index, (finish - start))
end
Expand All @@ -67,7 +67,7 @@ namespace :inpx do
puts title
authors = Parallel.map(Range.new(0, count - 1), in_processes: count) do |index|
start = Time.zone.now
authors = Authors::Parse.call(books: chunks[index])
authors = Authors::ParseService.call(books: chunks[index])
finish = Time.zone.now
puts format("Процесс %d: %0.2f сек", index, (finish - start))
authors.flatten.uniq
Expand All @@ -79,7 +79,7 @@ namespace :inpx do
puts title
keywords = Parallel.map(Range.new(0, count - 1), in_processes: count) do |index|
start = Time.zone.now
keywords = Keywords::Parse.call(books: chunks[index])
keywords = Keywords::ParseService.call(books: chunks[index])
finish = Time.zone.now
puts format("Процесс %d: %0.2f сек", index, (finish - start))
keywords.uniq
Expand All @@ -96,7 +96,7 @@ namespace :inpx do

Parallel.map(Range.new(0, count - 1), in_processes: count) do |index|
start = Time.zone.now
Books::Links.call(
Books::LinksService.call(
books: chunks[index],
genres_map: genres_map,
keywords_map: keywords_map,
Expand All @@ -106,10 +106,10 @@ namespace :inpx do
puts format("Процесс %d: %0.2f сек", index, (finish - start))
end

Authors::CounterCache.call
Genres::CounterCache.call
Keywords::CounterCache.call
Languages::CounterCache.call
Authors::CounterCacheCommand.call
Genres::CounterCacheCommand.call
Keywords::CounterCacheCommand.call
Languages::CounterCacheCommand.call

puts "Связей книг и авторов #{BooksAuthor.count}"
puts "Связей книг и ключевых слов #{BooksKeyword.count}"
Expand Down
2 changes: 1 addition & 1 deletion spec/services/authors/counter_cache_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe Authors::CounterCache do
RSpec.describe Authors::CounterCacheCommand do
subject(:operation) { described_class }

let(:fio) { 'Алешкин,Тимофей,Владимирович' }
Expand Down
2 changes: 1 addition & 1 deletion spec/services/authors/parse_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe Authors::Parse do
RSpec.describe Authors::ParseService do
subject(:operation) { described_class }

let(:books) { File.readlines('spec/fixtures/fb2-ru-ok-sf.inp') }
Expand Down
2 changes: 1 addition & 1 deletion spec/services/books/extract_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe Books::Extract do
RSpec.describe Books::ExtractService do
subject(:operation) { described_class }
let(:book) { create(:extract_book) }

Expand Down
2 changes: 1 addition & 1 deletion spec/services/books/links_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe Books::Links do
RSpec.describe Books::LinksService do
subject(:operation) { described_class }

let(:books) { File.readlines('spec/fixtures/fb2-ru-ok-sf.inp') }
Expand Down
2 changes: 1 addition & 1 deletion spec/services/books/parse_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe Books::Parse do
RSpec.describe Books::ParseService do
subject(:operation) { described_class }

let(:books) { File.readlines('spec/fixtures/fb2-ru-ok-sf.inp') }
Expand Down
2 changes: 1 addition & 1 deletion spec/services/folders/parse_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe Folders::Parse do
RSpec.describe Folders::ParseService do
subject(:operation) { described_class }

let(:books) { File.readlines('spec/fixtures/fb2-ru-ok-sf.inp') }
Expand Down
2 changes: 1 addition & 1 deletion spec/services/genres/counter_cache_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe Genres::CounterCache do
RSpec.describe Genres::CounterCacheCommand do
subject(:operation) { described_class }

before { inp_full_load('spec/fixtures/fb2-ru-ok-sf.inp') }
Expand Down
2 changes: 1 addition & 1 deletion spec/services/genres/parse_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe Genres::Parse do
RSpec.describe Genres::ParseService do
subject(:operation) { described_class }

let(:filename) { 'spec/fixtures/fb2-ru-ok-sf.inp' }
Expand Down
2 changes: 1 addition & 1 deletion spec/services/keywords/counter_cache_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe Keywords::CounterCache do
RSpec.describe Keywords::CounterCacheCommand do
subject(:operation) { described_class }

before { inp_full_load('spec/fixtures/fb2-ru-ok-sf.inp') }
Expand Down
2 changes: 1 addition & 1 deletion spec/services/keywords/parse_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe Keywords::Parse do
RSpec.describe Keywords::ParseService do
subject(:operation) { described_class }

let(:books) { File.readlines('spec/fixtures/fb2-ru-ok-sf.inp') }
Expand Down
2 changes: 1 addition & 1 deletion spec/services/languages/counter_cache_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe Languages::CounterCache do
RSpec.describe Languages::CounterCacheCommand do
subject(:operation) { described_class }

before { inp_full_load('spec/fixtures/fb2-ru-ok-sf.inp') }
Expand Down
2 changes: 1 addition & 1 deletion spec/services/languages/parse_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe Languages::Parse do
RSpec.describe Languages::ParseService do
subject(:operation) { described_class }

let(:filename) { 'spec/fixtures/fb2-ru-ok-sf.inp' }
Expand Down
10 changes: 5 additions & 5 deletions spec/support/loader_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def inp_full_load(path)

lines = File.readlines(path)

Books::Links.call(
Books::LinksService.call(
books: lines,
genres_map: Genre.pluck(:slug, :id).to_h,
keywords_map: Keyword.pluck(:name, :id).to_h,
Expand Down Expand Up @@ -51,21 +51,21 @@ def load_languages
end

def load_folders(lines)
folders = Folders::Parse.call(books: lines)
folders = Folders::ParseService.call(books: lines)
Folder.create(folders.map { |f| { name: f } })
end

def load_books(lines)
Books::Parse.call(books: lines)
Books::ParseService.call(books: lines)
end

def load_keywords(lines)
keywords = Keywords::Parse.call(books: lines)
keywords = Keywords::ParseService.call(books: lines)
Keyword.import keywords.uniq.map { |name| Keyword.new(name: name) }
end

def load_authors(lines)
authors = Authors::Parse.call(books: lines)
authors = Authors::ParseService.call(books: lines)
Author.import authors.flatten.uniq.map { |attr| Author.new(attr) }
end
end