-
-
Notifications
You must be signed in to change notification settings - Fork 393
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
refactor: Refactor the update_all_products.pl in Products.pm Fixes#7271 #8263
base: main
Are you sure you want to change the base?
Conversation
@stephanegigandet please help review |
lib/ProductOpener/Products.pm
Outdated
@@ -1001,6 +1001,25 @@ sub compute_sort_keys ($product_ref) { | |||
return; | |||
} | |||
|
|||
sub created_function($mongodb_to_mongodb, $product_ref, $products_collection, $data_root, $path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you rename the function "update_existing_product_without_creating_a_new_revision()" instead of "created_function()", so that it's easier to understand what it does?
lib/ProductOpener/Products.pm
Outdated
sub created_function($mongodb_to_mongodb, $product_ref, $products_collection, $data_root, $path) { | ||
|
||
# make sure nutrient values are numbers | ||
ProductOpener::Products::make_sure_numbers_are_stored_as_numbers($product_ref); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as this code is now in Products.pm, you can remove the "ProductOpener::Products::" part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay thank you @stephanegigandet
Thanks for the PR @oyenuga17 ! Overall it looks good, there are just a few things to address:
The reason I'm asking is that I think you will need to declare your new function at the top of Products.pm so that other scripts can use it. Thank you! |
@stephanegigandet Thank you so much i will put everything to use |
@stephanegigand i have made changes please review |
Product object reference. | ||
|
||
=head4 $products_collection | ||
=head4 $data_root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$data_root is a global variable, you can use it without passing it as an argument to the function
@@ -1323,22 +1323,8 @@ | |||
|
|||
# Otherwise, we silently update the .sto file of the last version | |||
else { | |||
|
|||
# make sure nutrient values are numbers | |||
ProductOpener::Products::make_sure_numbers_are_stored_as_numbers($product_ref); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you removed ProductOpener::Products::make_sure_numbers_are_stored_as_numbers($product_ref); from the script, but did not add it to the function.
Okay will see to it
…On Mon, 3 Apr 2023 at 09:13, Stéphane Gigandet ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In scripts/update_all_products.pl
<#8263 (comment)>
:
> @@ -1323,22 +1323,8 @@
# Otherwise, we silently update the .sto file of the last version
else {
-
- # make sure nutrient values are numbers
- ProductOpener::Products::make_sure_numbers_are_stored_as_numbers($product_ref);
I think you removed
ProductOpener::Products::make_sure_numbers_are_stored_as_numbers($product_ref);
from the script, but did not add it to the function.
—
Reply to this email directly, view it on GitHub
<#8263 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APKMDCRIHDSQYD5KOADHTOTW7KBA5ANCNFSM6AAAAAAWK7KBY4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
sub update_existing_product_without_creating_a_new_revision ($mongodb_to_mongodb, $product_ref, $products_collection, | ||
$data_root, $path) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# make sure nutrient values are numbers | |
ProductOpener::Products::make_sure_numbers_are_stored_as_numbers($product_ref); | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jnsereko if the sub is in same package I don't think you need the ProductOpener::Products::
prefix !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# make sure nutrient values are numbers | |
make_sure_numbers_are_stored_as_numbers($product_ref); |
@stephanegigandet please review .. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
@oyenuga17 can you fix the perl check ? It might be as easy as |
Kudos, SonarCloud Quality Gate passed! |
please merge .. i just ran the test |
@oyenuga17
From Unit tests:
|
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
@alexgarel @stephanegigandet is it possible/worth salvaging ? |
What
Refactor the update_all_products.pl script to use a new function update_existing_product_without_creating_a_new_revision()
Related issue(s) and discussion