Blacklist transitional/dummy stub packages from import
Their short description reliably says so (e.g. 'transitional package', 'transitional dummy package for foo'). Verified against production package data: 190 matches, none of them ever had a screenshot.
This commit is contained in:
parent
fd5747c6ab
commit
33fc169591
1 changed files with 24 additions and 1 deletions
|
|
@ -35,6 +35,14 @@ BLACKLIST_SECTION_PATTERN = [
|
|||
%r{/?libs$},
|
||||
]
|
||||
|
||||
# List of regular expressions. If the package's short description
|
||||
# matches any of these then the package will not be imported.
|
||||
# Transitional/dummy stub packages exist only to ease upgrades to a
|
||||
# renamed or split package and never get a useful screenshot.
|
||||
BLACKLIST_DESCRIPTION_PATTERN = [
|
||||
/transitional/i,
|
||||
]
|
||||
|
||||
# Whether to delete a blacklisted package from the database
|
||||
REMOVE_BLACKLISTED_PACKAGE = true
|
||||
|
||||
|
|
@ -87,7 +95,9 @@ namespace :debshots do
|
|||
Rails.logger.info "> Package: #{package[:Package]}"
|
||||
#Rails.logger.debug "Fetching package informaton from the database"
|
||||
|
||||
if package_name_blacklisted? package[:Package] or package_section_blacklisted? package[:Section]
|
||||
if package_name_blacklisted?(package[:Package]) or
|
||||
package_section_blacklisted?(package[:Section]) or
|
||||
package_description_blacklisted?(package[:Description])
|
||||
# Should the package get removed from the database?
|
||||
if REMOVE_BLACKLISTED_PACKAGE
|
||||
db_package = Package.find_by name: package[:Package]
|
||||
|
|
@ -280,3 +290,16 @@ def package_section_blacklisted?(section)
|
|||
end
|
||||
return false
|
||||
end
|
||||
|
||||
# Check if a package's short description marks it as a transitional or
|
||||
# dummy stub package (e.g. "transitional package", "transitional dummy
|
||||
# package for foo"). These never get a useful screenshot.
|
||||
def package_description_blacklisted?(description)
|
||||
BLACKLIST_DESCRIPTION_PATTERN.each do |pattern|
|
||||
if description.to_s =~ pattern
|
||||
Rails.logger.debug " > Blacklisted by description ('#{description}' matches '#{pattern}')"
|
||||
return true
|
||||
end
|
||||
end
|
||||
false
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue