diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 79e58346..24eb7c5b 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -147,6 +147,7 @@ module RepositoriesHelper ss_href = content.to_s.scan(href_regex) ss_href_1 = content.to_s.scan(href_regex_1) total_sources = {ss_c: ss_c,ss: ss, ss_1: ss_1, ss_2: ss_2, ss_src: ss_src, ss_src_1: ss_src_1, ss_src_2: ss_src_2, ss_src_3: ss_src_3, ss_src_4: ss_src_4, ss_src_5: ss_src_5, ss_href: ss_href, ss_href_1: ss_href_1} + puts total_sources # total_sources.uniq! total_sources.except(:ss, :ss_c).each do |k, sources| sources.each do |s| @@ -210,14 +211,14 @@ module RepositoriesHelper end end - after_ss_souces = content.to_s.scan(s_regex).uniq + after_ss_souces = content.to_s.scan(s_regex)#.uniq after_ss_souces.each_with_index do |s, index| + next if total_sources[:ss][index].nil? content = content.gsub("#{s[0]}","#{total_sources[:ss][index][0]}") end - after_ss_c_souces = content.to_s.scan(s_regex_c).uniq - puts after_ss_c_souces - puts total_sources + after_ss_c_souces = content.to_s.scan(s_regex_c)#.uniq after_ss_c_souces.each_with_index do |s, index| + next if total_sources[:ss_c][index].nil? content = content.gsub("#{s[0]}","#{total_sources[:ss_c][index][0]}") end return content diff --git a/app/jobs/daily_platform_statistics_job.rb b/app/jobs/daily_platform_statistics_job.rb index 5610f304..a65fa3c6 100644 --- a/app/jobs/daily_platform_statistics_job.rb +++ b/app/jobs/daily_platform_statistics_job.rb @@ -12,7 +12,7 @@ class DailyPlatformStatisticsJob < ApplicationJob ActiveJob::Base.logger.info "job baidu_tongji_auth access_token ===== #{access_token}" # 从最后一个记录日期开始,如果遗漏日期数据可以补充数据 last_date = DailyPlatformStatistic.order(:date).last - start_date = last_date.date + start_date = last_date.present? ? last_date.date : 1.days.ago.beginning_of_day end_date = Time.now if access_token.present? tongji_service.overview_batch_add(start_date, end_date)