From 24b14b9944ec15bac463c38d60ca8649d2fbb1e0 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Mon, 22 Jul 2019 16:32:40 +0800 Subject: [PATCH] add project package task --- app/models/project_package.rb | 2 +- app/tasks/check_project_package_deadline_task.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 app/tasks/check_project_package_deadline_task.rb diff --git a/app/models/project_package.rb b/app/models/project_package.rb index 4b160f99d..fc541097a 100644 --- a/app/models/project_package.rb +++ b/app/models/project_package.rb @@ -64,7 +64,7 @@ class ProjectPackage < ApplicationRecord def bidding_end? flag = deadline? - end_bidding! if flag && may_end_bidding? + ProjectPackages::EndBiddingService.call(self) if flag && may_end_bidding? flag end diff --git a/app/tasks/check_project_package_deadline_task.rb b/app/tasks/check_project_package_deadline_task.rb new file mode 100644 index 000000000..4ccec257e --- /dev/null +++ b/app/tasks/check_project_package_deadline_task.rb @@ -0,0 +1,12 @@ +class CheckProjectPackageDeadlineTask + def call + ProjectPackage.where(status: :published).where('deadline_at < ?', Time.now).find_each do |package| + begin + ProjectPackages::EndBiddingService.new(package).call + rescue => ex + Rails.logger.error ex.message + Rails.logger.error ex.backtrace.join('\n') + end + end + end +end