Closed atherdon closed 5 years ago
We've got two tables inside the PHP files, so I need to create two separate arrays of JS objects.
yes, you right
later, when we'll convert it into working json files - we'll also create it via js code at groceristar-fetch https://github.com/GroceriStar/groceristar-fetch/issues/312
What does this line mean ?
'pattern' => '[\d]{1,3}',
to be honest, i'm not quite remembered it... If you can create a separated task for this question - i'll later review my old project(it was done 3 years ago) and will be able to answer your question. When you'll create it - i'll close this task
Our another developer, Vadim - added some functionality, that will help us to generate some json files on the fly. please take a look on new functions that we have in this repo. Second stage for this task will be to make connecton, between 2 files, related to unit convertion programmarly. Tell me your questions and i'll add you more details upon request. Want to see how you can deal with this type of tasks
I've taken a look at the writeFile.js file. Now what 2 files need to be connected ?
This task is about unit conversion. And we have our 2 new files - related to unit conversion. My goal to make it similar and with the ability to change the logic/structure.
right now we have files: 1) https://github.com/GroceriStar/sd/blob/master/src/data/Units/measurementSystems.json 2) https://github.com/GroceriStar/sd/blob/master/src/data/Units/measurementUnits.json
1_ Systems: file, with a structure:
{
"id": "10",
"title": "Universal",
"alias": "universal"
},
we'll generate these structure by code. and we will simplify file to array with just titles or alias. Tell me if this is not clear
2_ Units file, with a structure
{
"id": "10",
"system_id": "20",
"type": "Weight",
"name": "Milligram",
"singular": "milligram",
"plural": "milligrams",
"short": "mg",
"pattern": "[\\d]{1,3}",
"error_message": "null"
},
will be also generated on the fly. at least ids, and error_message is not important - so we can add them at code.
let's think what steps we'll have in order to complete this task
So we’ll use the code that Vadim wrote to generate these files.
yeah, but it looks like that code is not finished as I wanted. But yeah - the main logic will be similar. Yesterday he pushed some updates, maybe in few days he'll complete it totally.
in mean time we can discuss with you first steps, that we can do
I think i find some details about units: https://github.com/ChickenKyiv/awesome-food-measurements-information don't worry :) We'll go by simple steps
check this video: https://www.loom.com/share/0229a998342046a986b51952dbd8f146
I've simplified the files, What else needs to be done ?
we need to connect them and generate a previous looking like file via generate script.
So the script is complete ?
@wahaj-47 yes, but it has one bug, before you will run generator you need create a folder.
For example filename userGrocery
, it will open folder UserGrocery
, and write userGrocery.js. first letter of filename make to uppercase. I will fix this bug.
How to use this: In https://github.com/GroceriStar/sd/blob/master/generateFiles.js#L18 is variable config - array of objects. you can comment four object and add yourself.
there is
{ "name": "usersGrocery",
"data": usersGrocery()
},
in property name put your filename that should be created. Then create folder with in /src/data/
but with first letter uppercase. then in property data add functionction that returns array. you can add your function in generateArray.js and import it ingenerateFiles.js
and use.
to run generator use
npm run generateFiles
to know that your file is created you will see in console about success of create file another you will see error
Alright got it.
@wahaj-47 can you fix test measurementSystems.test.js - it's faile. you can see it in https://travis-ci.org/GroceriStar/sd/jobs/524059567
@vadim9999 What next ?
I think we should close this issue.
close
I was thinking about our discussion, related to unit conversions... I actually think that we can start this thing too if you're ready to do it. From my side I have a lot of data collected. I'm just lazy to do it at this moment
So if you up to this thing, we can start from a simple task. I have a file, that was created by my partner. it's on PHP, but I'm sure you'll be able to crack it. Our goal is to convert that code into JSON objects/arrays. https://github.com/GroceriStar/sd-plain/blob/master/dirty/Measurements/data
@wahaj-47 tell me what do you think