-
-
Notifications
You must be signed in to change notification settings - Fork 400
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: separate products_obsolete MongoDB collection for obsolete products #8277
Conversation
You have successfully added a new SonarCloud configuration ``. As part of the setup process, we have scanned this repository and found no existing alerts. In the future, you will see all code scanning alerts on the repository Security tab. |
There are a few things that I didn't do yet. e.g. making some scripts or actions run on both products and products_obsolete collections (for instance when we rename the userid of users who want to have their username deleted). |
Codecov Report
@@ Coverage Diff @@
## main #8277 +/- ##
==========================================
- Coverage 46.61% 46.60% -0.01%
==========================================
Files 106 106
Lines 20787 20797 +10
Branches 4696 4700 +4
==========================================
+ Hits 9689 9693 +4
- Misses 9946 9949 +3
- Partials 1152 1155 +3
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Added a change in the CSV export to include obsolete products. |
Added a reference on #8270 |
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.
Cool
I added some concerns about robustness, I let you decide.
scripts/move_obsolete_products_to_products_obsolete_collection.pl
Outdated
Show resolved
Hide resolved
$products_collection->delete_one({"_id" => $product_ref->{_id}}); | ||
$obsolete_products_collection->replace_one({"_id" => $product_ref->{_id}}, $product_ref, {upsert => 1}); |
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.
Ain't it more prudent, especially for a migration, to do these operations on the inverse: first insert then remove.
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.
Sure, I'll invert the operations.
lib/ProductOpener/Products.pm
Outdated
previous_products_collection => $previous_products_collection | ||
} | ||
) if $log->is_debug(); | ||
$previous_products_collection->delete_one({"_id" => $product_ref->{_id}}); |
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'm asking myself if it wouldn't be better to do this at the end (maybe just store that we want to remove it here, but do it after insertion in its new collection).
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.
Also shan't we also consider the case of marked obsolete and moved to another collection (at least avoid a too complex situation, by eg. ignoring the obsolete status change in this case)
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'll move the delete after the insert.
The case of changed obsolete status and moved to another collection should work as-is (the product will be deleted twice from the previous collection, but that's not a problem).
Co-authored-by: Alex Garel <alex@garel.org>
Kudos, SonarCloud Quality Gate passed! |
Fixes #8078
This moves obsolete products to a new products_obsolete collection.
?obsolete=1 can be added to URLs to get them to return results from the products_obsolete collection.