Skip to content

Commit

Permalink
Merge pull request #257 from Shopify/update-shopify-taxonomy-version-…
Browse files Browse the repository at this point in the history
…for-mappings

Adjust Shopify taxonomy version for mappings in directory `/data/integrations`
  • Loading branch information
Catherine-Fu authored Aug 7, 2024
2 parents 6bce3fd + 7876a33 commit 0506dd7
Show file tree
Hide file tree
Showing 8 changed files with 284,053 additions and 7 deletions.
31 changes: 28 additions & 3 deletions app/commands/seed_local_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ class SeedLocalCommand < ApplicationCommand
permit ["taxonomy", "integrations"]
end

option :version do
desc "Distribution version"
short "-V"
long "--version string"
end

def execute
params[:targets] ||= ["taxonomy", "integrations"]
setup_options
frame("Seeding database") do
import_taxonomy if params[:targets].include?("taxonomy")
import_integrations if params[:targets].include?("integrations")
Expand All @@ -24,6 +30,11 @@ def execute

private

def setup_options
params[:targets] ||= ["taxonomy", "integrations"]
params[:version] ||= sys.read_file("VERSION").strip
end

def import_taxonomy
frame("Importing taxonomy") do
import_attributes_and_values
Expand Down Expand Up @@ -124,6 +135,8 @@ def validate_models
# TODO: this needs to be simplified
def mapping_rules_from(data)
mapping_rules = []
shopify_taxonomy_version = "shopify/" + params[:version]

data.each do |file|
logger.debug("→ #{file}")
from_shopify = File.basename(file, ".*").split("_")[0] == "from"
Expand All @@ -143,6 +156,18 @@ def mapping_rules_from(data)
input_type, output_type = output_type, input_type
end
rules = raw_mappings["rules"]
input_taxonomy = if raw_mappings["input_taxonomy"] == "shopify"
shopify_taxonomy_version
else
raw_mappings["input_taxonomy"]
end

output_taxonomy = if raw_mappings["output_taxonomy"] == "shopify"
shopify_taxonomy_version
else
raw_mappings["output_taxonomy"]
end

rules.each do |rule|
input_product_category_id = rule["input"]["product_category_id"]
input_product_category_full_name = if from_shopify
Expand Down Expand Up @@ -180,8 +205,8 @@ def mapping_rules_from(data)
output_id: output_product.id,
input_type: input_type,
output_type: output_type,
input_version: raw_mappings["input_taxonomy"],
output_version: raw_mappings["output_taxonomy"],
input_version: input_taxonomy,
output_version: output_taxonomy,
}
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
input_taxonomy: shopify/2024-07
input_taxonomy: shopify/2024-10-unstable
output_taxonomy: google/2021-09-21
rules:
- input:
Expand Down
2 changes: 1 addition & 1 deletion data/integrations/shopify/2022-02/mappings/to_shopify.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
input_taxonomy: shopify/2022-02
output_taxonomy: shopify/2024-07
output_taxonomy: shopify/2024-10-unstable
rules:
- input:
product_category_id: 1
Expand Down
4 changes: 2 additions & 2 deletions dist/en/integrations/all_mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"version": "2024-10-unstable",
"mappings": [
{
"input_taxonomy": "shopify/2024-07",
"input_taxonomy": "shopify/2024-10-unstable",
"output_taxonomy": "google/2021-09-21",
"rules": [
{
Expand Down Expand Up @@ -162825,7 +162825,7 @@
},
{
"input_taxonomy": "shopify/2022-02",
"output_taxonomy": "shopify/2024-07",
"output_taxonomy": "shopify/2024-10-unstable",
"rules": [
{
"input": {
Expand Down
Loading

0 comments on commit 0506dd7

Please sign in to comment.