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: "Barcode limit: 13 digits or more?" #86

Merged
merged 17 commits into from
Apr 15, 2022

Conversation

aadarsh-ram
Copy link
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 cquest and CharlesNepote 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
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.

db/migrations/change-barcodedef.py Show resolved Hide resolved
db/db-migration.py Outdated Show resolved Hide resolved
folksonomy/api.py Outdated Show resolved Hide resolved
Copy link
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.

db/db-migration.py Outdated Show resolved Hide resolved
db/db_settings.py Outdated Show resolved Hide resolved
folksonomy/models.py Outdated Show resolved Hide resolved
folksonomy/models.py Outdated Show resolved Hide resolved
folksonomy/models.py Outdated Show resolved Hide resolved
local_settings_example.py Outdated Show resolved Hide resolved
@aadarsh-ram aadarsh-ram requested a review from alexgarel April 6, 2022 11:48
db/db_setup.sql Outdated Show resolved Hide resolved
folksonomy/models.py Outdated Show resolved Hide resolved
folksonomy/api.py Outdated Show resolved Hide resolved
tests/test_main.py Show resolved Hide resolved
@alexgarel
Copy link
Member

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

folksonomy/models.py Outdated Show resolved Hide resolved
db-migration.py Show resolved Hide resolved
db/db_setup.sql Outdated Show resolved Hide resolved
local_settings_example.py Outdated Show resolved Hide resolved
INSTALL.md Outdated Show resolved Hide resolved
db-migration.py Outdated Show resolved Hide resolved
Copy link
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
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
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?

@CharlesNepote
Copy link
Member

@aadarsh-ram
Copy link
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
Status: Done
Development

Successfully merging this pull request may close these issues.

barcode limit: 13 digits or more?
5 participants