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

feat: Update populate_exec command to cater to upcoming variant changes #4469

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

Conversation

AfaqShuaib09
Copy link
Contributor

@AfaqShuaib09 AfaqShuaib09 commented Oct 16, 2024

PROD-4206

This PR updates populate_exec command to cater to upcoming variant changes.

Variants data will be split up into multiple keys. The new format is as follows:

{
  product: {
   ...
   variant: { ... },
   custom_persentations: [ { variant }, { variant } ],
   future_variants: [ { variant }, { variant } ]
  }
}

@AfaqShuaib09 AfaqShuaib09 marked this pull request as ready for review October 18, 2024 08:11
for variant in variants:
product.update({'variant': variant})
output_dict = self.get_transformed_data(row, product)
output_writer = self.write_csv_row(output_writer, output_dict)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest creating a new function, let's say get_variants. In there, instead of if-else, have a variant list that gets values extended or appended based on the key. The code will be readable and easy to understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

variants = []

for key in variant_keys:
if key in product:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if key in product only checks the presence of key. An additional check for truthy value is needed here.

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