Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added database:import_oldest_rpms[n] task

  • Loading branch information...
commit 9c767ea7ca2a91e84de44fe53dbd488183097094 1 parent 99fe231
nicolassatragno authored
Showing with 20 additions and 0 deletions.
  1. +10 −0 app/models/rpm_importer.rb
  2. +10 −0 lib/tasks/database.rake
View
10 app/models/rpm_importer.rb
@@ -5,6 +5,16 @@ class RpmImporter
BASE_URI = 'http://pkgs.fedoraproject.org/cgit/'
PKG_LIST_URI = BASE_URI + '?q=rubygem-'
+ def self.import_oldest(number)
+ total = 0
+ rpms = FedoraRpm.order("updated_at ASC").limit(number)
+ rpms.each { |f|
+ puts "Updating #{f.name} (#{total += 1}/#{rpms.size})..."
+ f.update_from_source
+ }
+
+ end
+
def self.import_all
total = 0
rpms = FedoraRpm.find(:all)
View
10 lib/tasks/database.rake
@@ -70,5 +70,15 @@ namespace :database do
end
GemImporter.update_gems(days)
end
+
+ desc 'import oldest n rpms'
+ task :update_oldest_rpms, [:rpms_number] => :environment do |t, args|
+ args.with_defaults(:rpms_number => 10)
+ number = args.rpms_number.to_i
+ unless number.nil? || number.is_a?(Fixnum)
+ raise ArgumentError, "invalid number of oldest rpms to import"
+ end
+ RpmImporter.import_oldest(number)
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.