diff --git a/app/jobs/link_metais_projects_and_evaluations_job.rb b/app/jobs/link_metais_projects_and_evaluations_job.rb index 0d46caa..77a13fe 100644 --- a/app/jobs/link_metais_projects_and_evaluations_job.rb +++ b/app/jobs/link_metais_projects_and_evaluations_job.rb @@ -3,12 +3,18 @@ class LinkMetaisProjectsAndEvaluationsJob < ApplicationJob def perform Project.find_each do |project| - code = project.metais_code - metais_project = Metais::Project.find_by(code: code) + link_metais_project(project) + end + end + + private + + def link_metais_project(project) + code = project.metais_code + metais_project = Metais::Project.find_by(code: code) - if metais_project.present? - project.metais_projects << metais_project - end + if metais_project.present? && !project.metais_projects.exists?(metais_project.id) + project.metais_projects << metais_project end end end \ No newline at end of file diff --git a/app/jobs/sync_all_topics_job.rb b/app/jobs/sync_all_topics_job.rb index 26ea1a0..895806b 100644 --- a/app/jobs/sync_all_topics_job.rb +++ b/app/jobs/sync_all_topics_job.rb @@ -21,9 +21,9 @@ def find_indices(header_row) end def process_row(row, indices, sync_all) - project_metais_code = row[indices["MetaIS"]] 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"]] diff --git a/config/clock.rb b/config/clock.rb index c050ec5..1b83ce9 100644 --- a/config/clock.rb +++ b/config/clock.rb @@ -12,8 +12,9 @@ module Clockwork Rake::Task[job].invoke end - every(1.day, 'redflags:sync', at: '9:00') + every(1.day, 'redflags:sync_google_drafts', at: '3:00') + every(1.day, 'redflags:sync_sheets', at: '4:00') - every(1.day, 'metais:daily_sync', at: '10:00') - every(1.day, 'metais:daily_sync_evaluations', at: '11:00') + every(1.day, 'metais:daily_sync', at: '5:00') + every(1.day, 'metais:daily_sync_evaluations', at: '6:00') end