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: issue #9876 import spreadsheet template with mandatory fields #9934

Merged
merged 6 commits into from
Mar 18, 2024

Conversation

himanshisrestha
Copy link
Contributor

What

This solves the issue #9876 import spreadsheet template with mandatory fields only on the producers platform.
In the import template generated by https://world.pro.openfoodfacts.org/cgi/generate_sample_import_file.pl , added a parameter "?fields=mandatory" to output the excel file with just the mandatory fields.
The issue was solved using param() function of the CGI.pm module. Before this, the code was setup to just find the importance of the header cell and then apply styling accordingly to write the cell. Using the param() function, the passed argument "fields=mandatory" was accepted as a name=value pair which made it easier to decide whether to add the the cell or not.
The change can be seen in the image attached, which returns an excel sheet consisting of 28 columns of mandatory fields only.

Screenshot

Screenshot 2024-03-18 at 2 43 40 AM

Related issue(s) and discussion

@@ -180,6 +180,7 @@ use ProductOpener::Config2;
stephane
tacinte
teolemon
himanshisrestha
Copy link
Contributor

Choose a reason for hiding this comment

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

This is good for testing, but it should not be included in the PR.

Copy link
Member

Choose a reason for hiding this comment

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

@himanshisrestha, when you test, use stephane or tacinte account to avoid having to change this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alexgarel could you please guide me on how to use it

Copy link
Member

Choose a reason for hiding this comment

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

you just go to sign-in -- create account and use the username "stephane"

.env Outdated
@@ -65,3 +65,4 @@ LOG_LEVEL_ROOT=TRACE
LOG_LEVEL_MONGODB=TRACE

BUILD_CACHE_REPO=openfoodfacts/openfoodfacts-build-cache
CPANMOPTS=--with-develop --with-feature=off_server_dev_tools
Copy link
Contributor

Choose a reason for hiding this comment

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

This should not be included in the PR

Copy link
Member

Choose a reason for hiding this comment

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

@himanshisrestha if you use linux or mac, you might use direnv

@stephanegigandet
Copy link
Contributor

Hello @himanshisrestha , thank you for the PR!

I made some comments. In addition, there are some code that was changed that we want to keep:

my $description = lang("description");
my $field_id;
my $comment;

$worksheet->set_row(0, 70);
$worksheet->set_column('A:ZZ', 30);
$worksheet->set_column('A:A', 30);
$worksheet->write($description_row, 0, $description, $formats{'description'});

This is needed in order to have "Description" translated in other languages.

Could you change the PR so that it contains only the one change for keeping only the mandatory fields? Thanks!

@stephanegigandet
Copy link
Contributor

Also you can run "make lint" to automatically format the code.

@himanshisrestha
Copy link
Contributor Author

Also you can run "make lint" to automatically format the code.

Yes, I can. I'm changing all what you mentioned and will update you soon.

@github-actions github-actions bot added Data import 🏭 Producers Platform https://wiki.openfoodfacts.org/Platform_for_producers labels Mar 18, 2024
Copy link

sonarcloud bot commented Mar 18, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@@ -64,4 +64,4 @@ ELASTICSEARCH_HOSTS=
LOG_LEVEL_ROOT=TRACE
LOG_LEVEL_MONGODB=TRACE

BUILD_CACHE_REPO=openfoodfacts/openfoodfacts-build-cache
BUILD_CACHE_REPO=openfoodfacts/openfoodfacts-build-cache
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this change is unrelated, could you remove it from the PR?

Copy link
Member

Choose a reason for hiding this comment

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

this is the last empty line which was removed. It sometimes depends on the IDE.

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.

Looks good to me! (except for the modification in .env file)

Thank you!

@himanshisrestha
Copy link
Contributor Author

Happy to mark my contribution ☺️

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 49.52%. Comparing base (dc04d18) to head (578e938).
Report is 124 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9934      +/-   ##
==========================================
- Coverage   49.54%   49.52%   -0.02%     
==========================================
  Files          67       71       +4     
  Lines       20650    20899     +249     
  Branches     4980     5019      +39     
==========================================
+ Hits        10231    10351     +120     
- Misses       9131     9254     +123     
- Partials     1288     1294       +6     

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

@stephanegigandet stephanegigandet merged commit 5dd0667 into openfoodfacts:main Mar 18, 2024
12 checks passed
@himanshisrestha himanshisrestha deleted the fix-#9876 branch March 20, 2024 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config Data import 🏭 Producers Platform https://wiki.openfoodfacts.org/Platform_for_producers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate an import spreadsheet template with mandatory fields only on the producers platform
4 participants