Merge pull request #605 from warpc/#604-Remove_old_buildlist_created_more_than_3_month_ago
#604 remove outdated buildlists
This commit is contained in:
commit
963b80cc93
|
@ -28,7 +28,8 @@ class BuildList < ActiveRecord::Base
|
|||
errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_repository')) unless save_to_repository_id.in? save_to_platform.repositories.map(&:id)
|
||||
}
|
||||
|
||||
LIVE_TIME = 3.week
|
||||
LIVE_TIME = 4.week # for unpublished
|
||||
MAX_LIVE_TIME = 3.month # for published
|
||||
|
||||
# The kernel does not send these statuses directly
|
||||
BUILD_CANCELED = 5000
|
||||
|
@ -97,7 +98,7 @@ class BuildList < ActiveRecord::Base
|
|||
s
|
||||
}
|
||||
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)
|
||||
scope :outdated, where('created_at < ? AND status <> ? OR created_at < ?', Time.now - LIVE_TIME, BUILD_PUBLISHED, Time.now - MAX_LIVE_TIME)
|
||||
|
||||
serialize :additional_repos
|
||||
serialize :include_repos
|
||||
|
|
|
@ -4,6 +4,7 @@ class MassBuild < ActiveRecord::Base
|
|||
has_many :build_lists, :dependent => :destroy
|
||||
|
||||
scope :by_platform, lambda { |platform| where(:platform_id => platform.id) }
|
||||
scope :outdated, where('created_at < ?', Time.now + 1.day - BuildList::MAX_LIVE_TIME)
|
||||
|
||||
attr_accessor :repositories, :arches
|
||||
attr_accessible :repositories, :arches, :auto_publish
|
||||
|
|
|
@ -89,7 +89,8 @@ class Project < ActiveRecord::Base
|
|||
# If main does not exist, will connect only project platform repository
|
||||
# If project platform repository is main, only main will be connect
|
||||
main_rep_id = platform.repositories.find_by_name('main').id
|
||||
build_reps_ids = ([main_rep_id] + [repository_id]).compact.uniq
|
||||
build_reps_ids = [main_rep_id, repository_id].compact.uniq
|
||||
|
||||
arch = Arch.find_by_name(arch) if arch.acts_like?(:string)
|
||||
build_lists.create do |bl|
|
||||
bl.save_to_platform = platform
|
||||
|
|
37
db/schema.rb
37
db/schema.rb
|
@ -107,8 +107,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
|
|||
t.integer "project_id"
|
||||
t.integer "arch_id"
|
||||
t.datetime "notified_at"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.boolean "is_circle", :default => false
|
||||
t.text "additional_repos"
|
||||
t.string "name"
|
||||
|
@ -138,8 +138,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
|
|||
t.string "commentable_type"
|
||||
t.integer "user_id"
|
||||
t.text "body"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.decimal "commentable_id", :precision => 50, :scale => 0
|
||||
t.integer "project_id"
|
||||
end
|
||||
|
@ -156,8 +156,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
|
|||
t.string "controller"
|
||||
t.string "action"
|
||||
t.text "message"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "flash_notifies", :force => true do |t|
|
||||
|
@ -187,8 +187,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
|
|||
t.string "title"
|
||||
t.text "body"
|
||||
t.string "status", :default => "open"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "user_id"
|
||||
t.datetime "closed_at"
|
||||
t.integer "closed_by"
|
||||
|
@ -248,8 +248,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
|
|||
t.string "description"
|
||||
t.string "name", :null => false
|
||||
t.integer "parent_platform_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.boolean "released", :default => false, :null => false
|
||||
t.integer "owner_id"
|
||||
t.string "owner_type"
|
||||
|
@ -317,8 +317,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
|
|||
|
||||
create_table "projects", :force => true do |t|
|
||||
t.string "name"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "owner_id"
|
||||
t.string "owner_type"
|
||||
t.string "visibility", :default => "open"
|
||||
|
@ -397,14 +397,13 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
|
|||
|
||||
create_table "users", :force => true do |t|
|
||||
t.string "name"
|
||||
t.string "email", :default => "", :null => false
|
||||
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
||||
t.string "password_salt", :default => "", :null => false
|
||||
t.string "email", :default => "", :null => false
|
||||
t.string "encrypted_password", :default => "", :null => false
|
||||
t.string "reset_password_token"
|
||||
t.datetime "reset_password_sent_at"
|
||||
t.datetime "remember_created_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "uname"
|
||||
t.string "role"
|
||||
t.string "language", :default => "en"
|
||||
|
@ -417,14 +416,14 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
|
|||
t.string "avatar_content_type"
|
||||
t.integer "avatar_file_size"
|
||||
t.datetime "avatar_updated_at"
|
||||
t.integer "failed_attempts", :default => 0
|
||||
t.integer "failed_attempts", :default => 0
|
||||
t.string "unlock_token"
|
||||
t.datetime "locked_at"
|
||||
t.string "confirmation_token"
|
||||
t.datetime "confirmed_at"
|
||||
t.datetime "confirmation_sent_at"
|
||||
t.string "authentication_token"
|
||||
t.integer "build_priority", :default => 50
|
||||
t.integer "build_priority", :default => 50
|
||||
end
|
||||
|
||||
add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token"
|
||||
|
|
|
@ -2,15 +2,19 @@
|
|||
namespace :buildlist do
|
||||
|
||||
namespace :clear do
|
||||
desc 'Remove outdated unpublished BuildLists'
|
||||
desc 'Remove outdated BuildLists and MassBuilds'
|
||||
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"
|
||||
say "Removing outdated MassBuilds"
|
||||
outdated = MassBuild.outdated
|
||||
say "There are #{outdated.count} outdated MassBuilds at #{Time.now}"
|
||||
MassBuild.outdated.destroy_all
|
||||
|
||||
say "Outdated BuildLists and MassBuilds was successfully removed"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue