-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add command to find unmapped external categories (#504)
Added a new CLI command to identify external taxonomy categories that aren't mapped from the Shopify taxonomy. This can be useful for helping identify gaps in the current taxonomy version. - Added a new `unmapped_external_categories` command to the CLI - Created `FindUnmappedExternalCategoriesCommand` to handle the logic - Added `unmapped_external_category_ids` method to `IntegrationVersion` to identify unmapped categories - Modified `Command` class to accept arguments in `run` and `execute` methods - Made `current_shopify_version` parameter optional in relevant methods ### Tophatting 1. Run the new CLI command: ```bash bin/product_taxonomy unmapped_external_categories [integration_name]/[version] ``` 2. Verify the output shows a list of category names that aren't mapped from the Shopify taxonomy
- Loading branch information
Showing
6 changed files
with
72 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
dev/lib/product_taxonomy/commands/find_unmapped_external_categories_command.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
module ProductTaxonomy | ||
class FindUnmappedExternalCategoriesCommand < Command | ||
def execute(name_and_version) | ||
load_taxonomy # not actually used in this operation, but required by IntegrationVersion to resolve categories | ||
|
||
unless name_and_version.match?(%r{\A[a-z0-9_-]+/[^/]+\z}) | ||
raise ArgumentError, "Invalid format. Expected 'name/version', got: #{name_and_version}" | ||
end | ||
|
||
# Load relevant IntegrationVersion using CLI argument | ||
integration_path = File.join(IntegrationVersion::INTEGRATIONS_PATH, name_and_version) | ||
integration_version = IntegrationVersion.load_from_source(integration_path:) | ||
|
||
# Output the unmapped external categories | ||
integration_version.unmapped_external_category_ids.each do |id| | ||
puts integration_version.full_names_by_id[id]["full_name"] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters