Skip to content
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

Merged
merged 1 commit into from
Jan 2, 2025
Merged

Update world taxon rake #1883

merged 1 commit into from
Jan 2, 2025

Conversation

ellohez
Copy link
Contributor

@ellohez ellohez commented Dec 18, 2024

  • 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:

Internal name = Living in Argentina
Skipping Living in Argentina as it already includes the country name

Internal name = Emergency help for British nationals (Argentina)
Updated taxon Emergency help for British nationals to Emergency help for British nationals in Argentina

Screenshot
ContentTagger - Updated world taxonomy

Worldwide taxonomy on Content tagger

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

@ellohez ellohez force-pushed the update-world-taxon-rake branch 7 times, most recently from 4ff3b24 to 658f345 Compare December 19, 2024 11:05
@ellohez ellohez marked this pull request as ready for review December 19, 2024 12:35
# (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}")
Copy link
Contributor

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

new_title = internal_name.gsub("(", "in ")
end
new_title.gsub!(")", "")
log_file ? log_file.puts(message) : puts(message)
Copy link
Contributor

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 ....

message = "Skipping #{internal_name} as it already includes the country name"
log_file ? log_file.puts(message) : puts(message)
next
end
Copy link
Contributor

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

@ellohez ellohez force-pushed the update-world-taxon-rake branch 3 times, most recently from 8d5bc0e to f8e243b Compare December 30, 2024 17:05
- 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
@ellohez ellohez force-pushed the update-world-taxon-rake branch from f8e243b to 6d37275 Compare December 30, 2024 17:08
@ellohez ellohez merged commit a947b24 into main Jan 2, 2025
10 checks passed
@ellohez ellohez deleted the update-world-taxon-rake branch January 2, 2025 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants