Skip to content

fix: "Barcode limit: 13 digits or more?"#86

Merged
alexgarel merged 17 commits intoopenfoodfacts:mainfrom
aadarsh-ram:change-barcode
Apr 15, 2022
Merged

fix: "Barcode limit: 13 digits or more?"#86
alexgarel merged 17 commits intoopenfoodfacts:mainfrom
aadarsh-ram:change-barcode

Conversation

@aadarsh-ram
Copy link
Copy Markdown
Contributor

@aadarsh-ram aadarsh-ram commented Apr 4, 2022

What

  • Folksonomy Engine recognizes products with 1-13 digit barcodes (regexp: [0-9]{1,13}) only.
  • As Folksonomy Engine can be used for other types of products, it must recognize barcodes with more than 13 digits.
  • This pull request aims to fix the above issue, as well as some other extra bugs found during testing.

Related issue(s)

File additions/deletions

  • Added a folder for database migration scripts. This folder can be used for future migration scripts as well.
  • Added a main migration script and a migration step file. Data migration is done using yoyo-migrations which has been added to the dependencies of Folksonomy Engine.
  • Added provisions for mentioning PostgresSQL user and host in local_settings_example.py
  • Changed regexp to check for barcodes with greater than 13 digits.
  • Changed table definitions of folksonomy and folksonomy_versions to include product barcodes of greater than 13 digits.
  • A barcode limit of 24 digits has been established after discussion.
  • Added a test with a barcode of 25 digits.
  • Removed the test which checks for greater than 14 digits barcodes.
  • Updated documentation

Part of

All unit tests which are part of test_main.py have passed.
Please do provide feedback after reviewing this PR. I hope that I will contribute more to OpenFoodFacts!

@aadarsh-ram aadarsh-ram requested a review from a team as a code owner April 4, 2022 16:36
@teolemon teolemon requested review from CharlesNepote and cquest April 4, 2022 16:50
@teolemon teolemon changed the title Fix for "Barcode limit: 13 digits or more?" Fix: "Barcode limit: 13 digits or more?" Apr 4, 2022
@teolemon teolemon changed the title Fix: "Barcode limit: 13 digits or more?" fix: "Barcode limit: 13 digits or more?" Apr 4, 2022
Copy link
Copy Markdown
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

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

LGTM, but I would like @CharlesNepote or @cquest to give their opinion.

Copy link
Copy Markdown
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

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

I added some remarks.

See in particular my comment for local_settings.py if it's not clear I may explain better.

@aadarsh-ram aadarsh-ram requested a review from alexgarel April 6, 2022 11:48
@alexgarel
Copy link
Copy Markdown
Member

@aadarsh-ram : to finish this request, I would say: just add a limit to barcode (32 is good I think).

Copy link
Copy Markdown
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

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

Sorry @aadarsh-ram still small comments, but we are very near the end !

@aadarsh-ram aadarsh-ram requested a review from alexgarel April 13, 2022 16:09
Copy link
Copy Markdown
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

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

Kudos @aadarsh-ram, good work.

@alexgarel alexgarel merged commit 2f33a80 into openfoodfacts:main Apr 15, 2022
@CharlesNepote
Copy link
Copy Markdown
Member

@aadarsh-ram @alexgarel : what should be the upgrade process then?
I started to document it here: https://github.com/openfoodfacts/openfoodfacts-infrastructure/blob/develop/docs/folksonomy.md#upgrade

But I guess I need to run a script for the DB migration?

@aadarsh-ram
Copy link
Copy Markdown
Contributor Author

aadarsh-ram commented Apr 12, 2023

@aadarsh-ram I added the https://github.com/openfoodfacts/folksonomy_api/blob/main/yoyo.ini file and wrote the upgrade documentation for our infrastructure: https://github.com/openfoodfacts/openfoodfacts-infrastructure/blob/develop/docs/folksonomy.md#upgrade

LGTM. FYI, you can use the command line interface or use the db_migrations.py script after setting the local_settings.py file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

barcode limit: 13 digits or more?

5 participants