Skip to content

Commit

Permalink
Revert this part, this will work on new version only
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasdrga committed Dec 9, 2024
1 parent 41c3041 commit 8df1f5e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
12 changes: 2 additions & 10 deletions app/jobs/sync_all_topics_job.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class SyncAllTopicsJob < ApplicationJob
queue_as :default

COLUMN_NAMES = ['Projekt', 'Projekt ID', 'MetaIS', 'Platforma', 'ID draft prípravy', 'ID prípravy', 'ID draft produktu', 'ID produktu'].freeze
COLUMN_NAMES = ['Projekt', 'Projekt ID', 'Platforma', 'ID draft prípravy', 'ID prípravy', 'ID draft produktu', 'ID produktu'].freeze

def perform(sync_all: true)
sheets_service = GoogleApiService.get_sheets_service
Expand All @@ -23,20 +23,12 @@ def find_indices(header_row)
def process_row(row, indices, sync_all)
project_name = row[indices["Projekt"]]
project_id = row[indices["Projekt ID"]]
project_metais_code = row[indices["MetaIS"]]
platform_link = row[indices["Platforma"]]
preparation_document_id = row[indices["ID draft prípravy"]]
preparation_page_id = row[indices["ID prípravy"]]
product_document_id = row[indices["ID draft produktu"]]
product_page_id = row[indices["ID produktu"]]


if project_metais_code.present?
project = Project.find_or_initialize_by(id: project_id)
project.metais_code = project_metais_code
project.save!
end

if sync_all
process_row_for_sync_all(project_name, project_id, platform_link, preparation_document_id, preparation_page_id, product_document_id, product_page_id)
else
Expand Down Expand Up @@ -72,4 +64,4 @@ def has_template_name?(document_id)
document_name = GoogleApiService.get_document(document_id)&.title
document_name == 'Kópia dokumentu RF-priprava-template' || document_name == 'Kópia dokumentu RF-produkt-template'
end
end
end
25 changes: 11 additions & 14 deletions spec/jobs/sync_all_topics_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,15 @@
[
[],
[],
['Projekt', 'Projekt ID', 'MetaIS', 'Platforma', 'ID draft prípravy', 'ID prípravy', 'ID draft produktu', 'ID produktu'],
['Projekt1', 1, '', '', 'ABC1', 'ABC1', 'ABC1', 'ABC1'],
['Projekt2', 2, 'projekt_2741', '', 'ABC2', 'ABC2', 'ABC2', 'ABC2']
['Projekt', 'Projekt ID', 'Platforma', 'ID draft prípravy', 'ID prípravy', 'ID draft produktu', 'ID produktu'],
['Projekt1', 'ABC1', '', 'ABC1', 'ABC1', 'ABC1', 'ABC1'],
['Projekt2', 'ABC2', '', 'ABC2', 'ABC2', 'ABC2', 'ABC2']
]
end

let(:indices) { { 'Projekt' => 0, 'Projekt ID' => 1, 'MetaIS' => 2,'Platforma' => 3, 'ID draft prípravy' => 4, 'ID prípravy' => 5, 'ID draft produktu' => 6, 'ID produktu' => 7 } }
let(:indices) { { 'Projekt' => 0, 'Projekt ID' => 1, 'Platforma' => 2, 'ID draft prípravy' => 3, 'ID prípravy' => 4, 'ID draft produktu' => 5, 'ID produktu' => 6 } }

before do
Project.create(id: 1)
Project.create(id: 2)

mock_document = instance_double("Google::Apis::DocsV1::Document")
allow(mock_document).to receive(:title).and_return("Dokument RF-priprava-template")
allow(GoogleApiService).to receive(:get_document).and_return(mock_document)
Expand All @@ -48,8 +45,8 @@
[],
[],
['Projekt'],
['Projekt1', 1, '', 'ABC1', 'ABC1', 'ABC1', 'ABC1'],
['Projekt2', 2, 'projekt_2741', 'http://google.com', 'ABC2', 'ABC2', 'ABC2', 'ABC2']
['Projekt1', 'ABC1', '', 'ABC1', 'ABC1', 'ABC1', 'ABC1'],
['Projekt2', 'ABC2', 'http://google.com', 'ABC2', 'ABC2', 'ABC2', 'ABC2']
]
end

Expand All @@ -64,7 +61,7 @@
[
[],
[],
['Projekt', 'Projekt ID', 'MetaIS', 'Platforma', 'ID draft prípravy', 'ID prípravy', 'ID draft produktu', 'ID produktu']
['Projekt', 'Projekt ID', 'Platforma', 'ID draft prípravy', 'ID prípravy', 'ID draft produktu', 'ID produktu']
]
end

Expand All @@ -79,9 +76,9 @@
[
[],
[],
['Projekt', 'Projekt ID', 'MetaIS', 'Platforma', 'ID draft prípravy', 'ID prípravy', 'ID draft produktu', 'ID produktu'],
['Projekt1', 1, '', '', 'ABC1', '', 'ABC1', ''],
['Projekt2', 2, 'projekt_2741', 'http://google.com', 'ABC2', 'ABC2', 'ABC2', 'ABC2']
['Projekt', 'Projekt ID', 'Platforma', 'ID draft prípravy', 'ID prípravy', 'ID draft produktu', 'ID produktu'],
['Projekt1', 'ABC1', '', 'ABC1', '', 'ABC1', ''],
['Projekt2', 'ABC2', 'http://google.com', 'ABC2', 'ABC2', 'ABC2', 'ABC2']
]
end

Expand All @@ -91,4 +88,4 @@
described_class.perform_now
end
end
end
end

0 comments on commit 8df1f5e

Please sign in to comment.