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

Automatically resolve to_shopify mapping chain from oldest to current version #517

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

danielpgross
Copy link
Collaborator

@danielpgross danielpgross commented Dec 20, 2024

TL;DR

Changes how integration mappings are defined from older Shopify taxonomy versions.

Before:

  • In data, old Shopify integration versions were defined relative to the current/latest version (ex. 2022-01 is defined relative to 2025-01-unstable)
    • Pain point: every time we added a new to_shopify mapping, we needed to also add it individually to each older version.
  • In dist, old Shopify integration versions were generated relative to the current version

After:

  • In data, old Shopify integration versions are defined relative to the immediately next version (ex. 2022-01 is defined relative to 2024-07)
  • In dist, old Shopify integration versions are generated relative to the current version

How it works

  • When initially loading MappingRules, category IDs are no longer resolved to Category objects using the current taxonomy. Instead, the raw category ID is stored.
  • After all mappings to Shopify have been loaded, the category IDs are resolved:
    • We start from the newest integration version and resolve its category IDs against the current taxonomy.
    • We then move backwards one version at a time, resolving each version against the immediate next one.
  • Once this process is done, each integration version has had its category IDs resolved to Category objects, taking into account any mappings that appear in newer versions.

Breakdown of changes

The PR is big, but most of the changes are test fixtures. The actual implementation changes are mostly in:

  • IntegrationVersion#load_all_from_source
  • IntegrationVersion#resolve_to_shopify_mappings

The other notable change is extracting out one of the tests from IntegrationVersionTest into a dedicated integration test (GenerateMappingsDistTest). Instead of heavily relying on mocking like the old test, the new dedicated test compares generated file contents against fixtures. This approach is more straightforward and easier to maintain.

Copy link
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@danielpgross danielpgross force-pushed the 12-20-wip_resolve_to_shopify_mappings_from_intermediate_versions_to_latest branch 6 times, most recently from 2cd98b0 to e2f3857 Compare January 2, 2025 21:06
@danielpgross danielpgross changed the title WIP: Resolve to_shopify mappings from intermediate versions to latest Resolve to_shopify mappings from old versions to latest Jan 2, 2025
@danielpgross danielpgross changed the title Resolve to_shopify mappings from old versions to latest Automatically resolve to_shopify mapping chain from oldest to latest version Jan 2, 2025
@danielpgross danielpgross changed the title Automatically resolve to_shopify mapping chain from oldest to latest version Automatically resolve to_shopify mapping chain from oldest to current version Jan 2, 2025
@danielpgross danielpgross marked this pull request as ready for review January 2, 2025 21:44
@danielpgross danielpgross force-pushed the 12-20-wip_resolve_to_shopify_mappings_from_intermediate_versions_to_latest branch from e2f3857 to 2add753 Compare January 2, 2025 21:47
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.

1 participant