Merge pull request #446 from warpc/430-clearing_build_lists
[issue #430] Added rake task to remove outdated BuildLists and setup it to everyday starting.
This commit is contained in:
commit
8c703f413d
|
@ -23,6 +23,8 @@ class BuildList < ActiveRecord::Base
|
||||||
errors.add(:build_for_platform, I18n.t('flash.build_list.wrong_platform')) if save_to_platform.platform_type == 'main' && save_to_platform_id != build_for_platform_id
|
errors.add(:build_for_platform, I18n.t('flash.build_list.wrong_platform')) if save_to_platform.platform_type == 'main' && save_to_platform_id != build_for_platform_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LIVE_TIME = 3.week
|
||||||
|
|
||||||
# The kernel does not send these statuses directly
|
# The kernel does not send these statuses directly
|
||||||
BUILD_CANCELED = 5000
|
BUILD_CANCELED = 5000
|
||||||
WAITING_FOR_RESPONSE = 4000
|
WAITING_FOR_RESPONSE = 4000
|
||||||
|
@ -89,9 +91,11 @@ class BuildList < ActiveRecord::Base
|
||||||
}
|
}
|
||||||
scope :scoped_to_project_name, lambda {|project_name| joins(:project).where('projects.name LIKE ?', "%#{project_name}%")}
|
scope :scoped_to_project_name, lambda {|project_name| joins(:project).where('projects.name LIKE ?', "%#{project_name}%")}
|
||||||
|
|
||||||
|
scope :outdated, where('updated_at < ? AND status <> ?', Time.now - LIVE_TIME, BUILD_PUBLISHED)
|
||||||
|
|
||||||
serialize :additional_repos
|
serialize :additional_repos
|
||||||
serialize :include_repos
|
serialize :include_repos
|
||||||
|
|
||||||
before_create :set_default_status
|
before_create :set_default_status
|
||||||
after_create :place_build
|
after_create :place_build
|
||||||
|
|
||||||
|
|
|
@ -10,3 +10,7 @@
|
||||||
every 1.day, :at => '4:00 am' do
|
every 1.day, :at => '4:00 am' do
|
||||||
rake "import:sync:all", :output => 'log/sync.log'
|
rake "import:sync:all", :output => 'log/sync.log'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
every 1.day, :at => '3:50 am' do
|
||||||
|
rake "buildlist:clear:outdated", :output => 'log/build_list_clear.log'
|
||||||
|
end
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
namespace :buildlist do
|
||||||
|
|
||||||
|
namespace :clear do
|
||||||
|
desc 'Remove outdated unpublished BuildLists'
|
||||||
|
task :outdated => :environment do
|
||||||
|
say "Removing outdated BuildLists"
|
||||||
|
outdated = BuildList.outdated
|
||||||
|
say "There are #{outdated.count} outdated BuildLists at #{Time.now}"
|
||||||
|
|
||||||
|
BuildList.outdated.destroy_all
|
||||||
|
|
||||||
|
say "Outdated BuildLists was successfully removed"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue