Optimisation: only query database if the package is not obviously blacklisted

Performance gain: 20x
This commit is contained in:
Christoph Haas 2015-04-20 20:33:40 +02:00
parent 9b3f05bad9
commit 13218841f4

View file

@ -74,11 +74,10 @@ task :import_debian => :environment do
Rails.logger.info "> Package: #{package[:Package]}"
#Rails.logger.debug "Fetching package informaton from the database"
db_package = Package.find_by name: package[:Package]
if package_blacklisted? package
# Should the package get removed from the database?
if REMOVE_BLACKLISTED_PACKAGE
db_package = Package.find_by name: package[:Package]
if db_package
Rails.logger.info "Removing blacklisted package '#{package[:Package]}' from database"
db_package.destroy
@ -88,6 +87,7 @@ task :import_debian => :environment do
next
end # if blacklisted
db_package = Package.find_by name: package[:Package]
unless db_package
Rails.logger.debug "No such package in our database."
next