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

Units migration - default units: Automatically detect imperial/metric units #35

Closed
lentschi opened this issue Jan 12, 2024 · 1 comment
Assignees

Comments

@lentschi
Copy link
Contributor

lentschi commented Jan 12, 2024

When migrating to the new unit schema, automatically detect whether there are any metric/imperial units in the old db and add default units accordingly. see #24

For seeds, make it depend on the seed's locale.

@lentschi lentschi added this to the Feature complete milestone Jan 12, 2024
@lentschi lentschi self-assigned this Jan 12, 2024
lentschi added a commit that referenced this issue Apr 6, 2024
lentschi added a commit that referenced this issue Apr 12, 2024
@lentschi
Copy link
Contributor Author

lentschi commented Apr 12, 2024

@twothreenine @yksflip
I think this might be done and will close this for now.

The logic I implemented to detect whether there are any imperial units in the db is here:

plain_text_units.any? { |plain_text_unit| /(?:\s|[0-9])+(?:oz|lb)\s*$/.match(plain_text_unit) }

<- That means, if there's any old plaintext unit ending in oz or lb, it will add imperial units to the default units available in the article master data form after the initial migration.

As for the list of default units, I have now configured the following (to see to which unit a code is referring either use the article units index in the foodsoft fork or check out Leo's excel files in #10):

Piece units: PTN, STC, XCU, XCN, XSH, X43, XST, XOK, XVA, XBX, XBH, XBE, XCX, XBJ, XUN, XOS, XDH, XBA, XFI, XBO, XBQ, XFB, XFT, XJR, XGR, XOW, X8B, XCV, XWA, XEI, XJT, XGY, XJY, XBD, XCR, XAI, XPA, XBK, XBI, XOV, XNT, XPK, XPC, XPX, X5M, XPR, XEC, X6H, X44, XBR, XCW, XBT, XSA, XBM, XSX, XDN, XAE, XSC, XLU, X5L, XPP, XPU, XBG, XP2, XCK, XPT, XGI, XTU

Metric scalar units: KGM, HGM, DJ, LTR, DLT, CLT, MLT

Imperial scalar units: LBR, ONZ, GLL, QTI, PTI

Regarding the seeds, I've added it to the temporary hackathon seeds in German (without imperial units) and English (with imperial units). This part will obviously have to be copied when we finally implement #16.

If you want to correct anything about that, please comment & reopen.

lentschi added a commit that referenced this issue May 4, 2024
lentschi added a commit that referenced this issue May 4, 2024
lentschi added a commit that referenced this issue May 4, 2024
lentschi added a commit that referenced this issue May 4, 2024
lentschi added a commit that referenced this issue May 24, 2024
lentschi added a commit that referenced this issue May 24, 2024
lentschi added a commit that referenced this issue Jul 26, 2024
lentschi added a commit that referenced this issue Jul 26, 2024
lentschi added a commit that referenced this issue Oct 11, 2024
lentschi added a commit that referenced this issue Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant