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

Pi/updating variants bug #2604

Merged

Conversation

Matt-Yorkley
Copy link
Contributor

@Matt-Yorkley Matt-Yorkley commented Aug 28, 2018

What? Why?

Closes #2602

Fixes some old logic on finding/matching products when updating existing variants that was leading to strange user feedback in the validation step, and improved some related specs.

What should we test?

Issue outlined in Slack channel with example large CSV file. Validation should now be working correctly during import.

Release notes

Fixed validation issue when updating existing products during product import.

Changelog Category: Fixed

@Matt-Yorkley Matt-Yorkley self-assigned this Aug 28, 2018
Copy link
Member

@mkllnk mkllnk left a comment

Choose a reason for hiding this comment

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

Nice testing. From your commit history I can't actually see which spec is covering the fix you did and which specs are just additional coverage. I think the commit messages could explain the intent better or some of the commits could have been squashed together to ease reviewing. :-)

mark_as_invalid(entry, attribute: 'name', error: I18n.t('admin.product_import.model.no_product'))
return
end

match.variants.each do |existing_variant|
unit_scale = match.variant_unit_scale
products.map(&:variants).flatten.each do |existing_variant|
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel this can be simpler with #flat_map

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I didn't know about #flat_map

mark_as_new_product(entry)
return
end

# Otherwise, if a variant exists with matching display_name and unit_value, update it
match.variants.each do |existing_variant|
products.map(&:variants).flatten.each do |existing_variant|
Copy link
Contributor

Choose a reason for hiding this comment

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

here as well

expect(page).to_not have_selector '.invalid-count'
expect(page).to have_selector '.create-count', text: "2"
expect(page).to_not have_selector '.update-count'
expect(page).to_not have_selector '.update-count'
Copy link
Contributor

Choose a reason for hiding this comment

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

duplicate?

@Matt-Yorkley Matt-Yorkley force-pushed the pi/updating_variants_bug branch from c1ca1cb to 4dfbbd6 Compare August 31, 2018 18:47
@Matt-Yorkley
Copy link
Contributor Author

@sauloperez It'd be great for the UK if we could get these little bug fixes into the next release as we will need this on production... 🙏

@sauloperez
Copy link
Contributor

Sorry, I forgot about this one.

@myriamboure
Copy link
Contributor

Please folks let us know with a comment when you stage something so we receive a notification ;-) I'm not sure how we should test this one as it was for a specific case bugging in the UK. @Matt-Yorkley @lin-d-hop do we know what caused the bug more specifically so we can do a proper testing? I'm happy to test but I don't know what to test exactly... in the issue I don't know what was in the file that was imported...

@sauloperez
Copy link
Contributor

Sorry @myriamboure, I thought you go check the test ready column in ZenHub

@RachL
Copy link
Contributor

RachL commented Sep 6, 2018

@sauloperez @myriamboure Actually I do go through the zenhub column and I think @sstead is doing that too. So I really just need the label and the assigned tester if there s already one. As we said Myriam that I would ask you when you need to test, I think there is no need for comments. Do you agree ?

@myriamboure
Copy link
Contributor

Hum... @RachL I think we discussed and agreed to do both to avoid confusion, that's what we wrote in the process. So I would suggest we try the process we decided and if it doesn't work then we adapt? Cause some devs only put message and no label, some do the other side and some do both so let's try to let people do the same thing and see how it works?

@RachL
Copy link
Contributor

RachL commented Sep 6, 2018

@myriamboure as you wish. But so far I've never had an issue with the label. So that's why if it's easier I'm proposing this.

@luisramos0
Copy link
Contributor

from slack:
matt-yorkley [1:07 PM]
we've actually tested #2604 in the UK and are happy with it's changes, not sure if that's enough or we want extra testing. what do you think @lin-d-hop ? (edited)

@lin-d-hop ;-)

@daniellemoorhead
Copy link
Contributor

Sorry @myriamboure, I thought you go check the test ready column in ZenHub

One thing that makes finding staged things easier @sauloperez @luisramos0 @Matt-Yorkley @mkllnk is to make sure they're at the top of the test ready column. Yesterday I moved the pr-staged-es up because it was lost further down the list.

Just spoke to @sstead and she doesn't mind with/without a comment. She comes in on her day and looks for staged things on AU and then throughout the day she and Maikel communicate on slack when things are staged/tested.

@daniellemoorhead
Copy link
Contributor

from slack:
matt-yorkley [1:07 PM]
we've actually tested #2604 in the UK and are happy with it's changes, not sure if that's enough or we want extra testing. what do you think @lin-d-hop ?

Given this ☝️ I'm moving PR to the Ready to Go column. @lin-d-hop move it back if this isn't the case.

@mkllnk
Copy link
Member

mkllnk commented Sep 7, 2018

screenshot from 2018-09-07 15-07-56

@mkllnk mkllnk merged commit 3e0c744 into openfoodfoundation:master Sep 7, 2018
@RachL
Copy link
Contributor

RachL commented Sep 7, 2018

actually I didn't test it...I was waiting for a confirmation in the slack product import channel to know what to test :( @daniellemoorhead

@RachL RachL removed the pr-staged-es label Sep 7, 2018
@daniellemoorhead
Copy link
Contributor

Uh oh... looks like I read the comment stream incorrectly 😱

Not sure what to do now that it's merged... @RachL @Matt-Yorkley suggestions?

@Matt-Yorkley
Copy link
Contributor Author

Matt-Yorkley commented Sep 7, 2018

We were testing this on staging with large and complex inputs to get it right, and we quietly pushed this branch to UK production about a week ago so we could use it live (once we were satisfied). It's been used since and is working correctly without any problems.

@daniellemoorhead
Copy link
Contributor

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.

8 participants