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

unit convertion. intro #55

Closed
atherdon opened this issue Mar 24, 2019 · 22 comments
Closed

unit convertion. intro #55

atherdon opened this issue Mar 24, 2019 · 22 comments
Assignees

Comments

@atherdon
Copy link
Contributor

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

@wahaj-47
Copy link
Collaborator

wahaj-47 commented Apr 4, 2019

We've got two tables inside the PHP files, so I need to create two separate arrays of JS objects.

@atherdon
Copy link
Contributor Author

atherdon commented Apr 4, 2019

yes, you right

@atherdon
Copy link
Contributor Author

atherdon commented Apr 4, 2019

later, when we'll convert it into working json files - we'll also create it via js code at groceristar-fetch
GroceriStar/groceristar-fetch#312

@wahaj-47
Copy link
Collaborator

wahaj-47 commented Apr 4, 2019

What does this line mean ?

'pattern' => '[\d]{1,3}',

@atherdon
Copy link
Contributor Author

atherdon commented Apr 4, 2019

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

@atherdon
Copy link
Contributor Author

atherdon commented Apr 5, 2019

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

@wahaj-47
Copy link
Collaborator

wahaj-47 commented Apr 6, 2019

I've taken a look at the writeFile.js file. Now what 2 files need to be connected ?

@atherdon
Copy link
Contributor Author

atherdon commented Apr 6, 2019 via email

@atherdon
Copy link
Contributor Author

atherdon commented Apr 6, 2019

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

@wahaj-47
Copy link
Collaborator

wahaj-47 commented Apr 7, 2019

So we’ll use the code that Vadim wrote to generate these files.

@atherdon
Copy link
Contributor Author

atherdon commented Apr 7, 2019

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

@atherdon
Copy link
Contributor Author

atherdon commented Apr 7, 2019

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

@atherdon
Copy link
Contributor Author

atherdon commented Apr 9, 2019

@wahaj-47
Copy link
Collaborator

I've simplified the files, What else needs to be done ?

@atherdon
Copy link
Contributor Author

atherdon commented Apr 17, 2019 via email

@wahaj-47
Copy link
Collaborator

So the script is complete ?

@vadim9999
Copy link
Collaborator

@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

@wahaj-47
Copy link
Collaborator

Alright got it.

@vadim9999
Copy link
Collaborator

@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

@wahaj-47
Copy link
Collaborator

@vadim9999 What next ?

@wahaj-47
Copy link
Collaborator

I think we should close this issue.

@vadim9999
Copy link
Collaborator

close

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

3 participants