-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update world taxon rake #1883
Update world taxon rake #1883
Conversation
4ff3b24
to
658f345
Compare
lib/tasks/world_taxon_update.rake
Outdated
# (common ancestor e.g. /world/all - Help and services around the world) as the root | ||
taxonomy = Taxonomy::ExpandedTaxonomy.new(ROOT_CONTENT_ID).build.child_expansion | ||
log_file&.puts("Taxonomy has size #{taxonomy.tree.size}") | ||
puts("Taxonomy has size #{taxonomy.tree.size}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider refactoring this bit of a code (and similar occurrences below)
log_file&.puts(message)
puts(message)
into method to avoid duplications
lib/tasks/world_taxon_update.rake
Outdated
new_title = internal_name.gsub("(", "in ") | ||
end | ||
new_title.gsub!(")", "") | ||
log_file ? log_file.puts(message) : puts(message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving "new title" building code into separate method, too. It could be something like below, using case statement for more clarity.
def create_new_title(internal_name)
case internal_name
when ....
lib/tasks/world_taxon_update.rake
Outdated
message = "Skipping #{internal_name} as it already includes the country name" | ||
log_file ? log_file.puts(message) : puts(message) | ||
next | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we take lines 31, and 42-45 into one separate conditional method we can call in line 31, something like:
next if skip_item?(linked_item)
. We will only need to remember to use linked_item.internal_name
as internal_name
will be defined later
8d5bc0e
to
f8e243b
Compare
- Log errors to stdout AND log file - DRY out code by creating methods for: - Logging, creating the new title and testing if the current taxon should be skipped
f8e243b
to
6d37275
Compare
This rake task was created to update the world taxonomy titles to include the name of the country which the page relates to. This is achieved by copying the name of the country from the internal name.
Included is a rake task to revert the taxon titles to their previous state by removing the country name which is useful for testing the task on Integration.
As some of the titles already include the name of the country, these are skipped, as are the root taxon and any taxons for GENERIC template pages as these do not relate to a specific country.
See the Trello Card for information on why this is necessary to meet WCAG (accessibility guidelines).
Example test log output:
Screenshot
Worldwide taxonomy on Content tagger