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

fix: Automatically unselect images when source image is deleted #10692

Merged

Conversation

4nt0ineB
Copy link
Member

What

Automatically unselect images when source image is deleted

Related issue(s) and discussion

@4nt0ineB 4nt0ineB requested a review from a team as a code owner August 13, 2024 10:36
@4nt0ineB 4nt0ineB added Data import 🏭 Producers Platform https://wiki.openfoodfacts.org/Platform_for_producers labels Aug 13, 2024
if ($move_to eq 'trash') {
foreach my $related_img (keys %{$product_ref->{images}}) {
if ($product_ref->{images}{$related_img}{imgid} eq $imgid) {
_process_image_unselect($product_ref, $related_img);
Copy link
Contributor

Choose a reason for hiding this comment

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

We want to unselect the image, but we also want to move the selected image files (similar to the source file with the code above) so that they are not visible online any longer as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, I made changes. I use a queue for the images to be moved and If an image has to be unselected because the source is trashed, we add it to the queue to trash it too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perfect, thank you!

@codecov-commenter
Copy link

codecov-commenter commented Aug 13, 2024

Codecov Report

Attention: Patch coverage is 0% with 17 lines in your changes missing coverage. Please review.

Project coverage is 49.35%. Comparing base (dc04d18) to head (d6d9066).
Report is 575 commits behind head on main.

Files Patch % Lines
lib/ProductOpener/Images.pm 0.00% 16 Missing ⚠️
lib/ProductOpener/Food.pm 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10692      +/-   ##
==========================================
- Coverage   49.54%   49.35%   -0.20%     
==========================================
  Files          67       77      +10     
  Lines       20650    22025    +1375     
  Branches     4980     5261     +281     
==========================================
+ Hits        10231    10870     +639     
- Misses       9131     9827     +696     
- Partials     1288     1328      +40     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@stephanegigandet stephanegigandet left a comment

Choose a reason for hiding this comment

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

Thank you!

@stephanegigandet
Copy link
Contributor

/lint

@stephanegigandet
Copy link
Contributor

/update_tests_results

Copy link

sonarcloud bot commented Aug 13, 2024

@stephanegigandet stephanegigandet merged commit 588897a into openfoodfacts:main Aug 13, 2024
12 checks passed
stephanegigandet pushed a commit that referenced this pull request Aug 13, 2024
🤖 I have created a release *beep* *boop*
---


##
[2.41.0](v2.40.0...v2.41.0)
(2024-08-13)


### Features

* generate historical events from product revisions
([#10523](#10523))
([42508e1](42508e1))
* sync number of product public/pro in CRM
([#10684](#10684))
([026ff6a](026ff6a))


### Bug Fixes

* 3 fixes to make /products/[code1],[code2] work again
([#10669](#10669))
([7fc07fc](7fc07fc))
* Automatically unselect images when source image is deleted
([#10692](#10692))
([588897a](588897a))
* **docs:** correct OpenAPI definition by fixing missing reference
([#10659](#10659))
([4f0f10e](4f0f10e))
* gen_users_emails.pl
([#10686](#10686))
([00e4c26](00e4c26))
* Show missing nutrients in Nutri-Score panel
([#10655](#10655))
([a1b11eb](a1b11eb))
* UTM mobile
([#10665](#10665))
([965041d](965041d))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Data import Food.pm 🖼️ Images 🏭 Producers Platform https://wiki.openfoodfacts.org/Platform_for_producers 🧪 tests
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Automatically unselect images when source image is deleted
3 participants