Added uploader for legacy data
This commit is contained in:
parent
101cf784f2
commit
077cb0b774
21
src/uploader/ComponentUploader.js
Normal file
21
src/uploader/ComponentUploader.js
Normal file
@ -0,0 +1,21 @@
|
||||
const fs = require('fs');
|
||||
const firebase = require('firebase');
|
||||
|
||||
(function() {
|
||||
firebase.initializeApp({
|
||||
apiKey: "AIzaSyC7BFq-px3_XBC4VbV5noRDB4yK2Gfvz24",
|
||||
authDomain: "fhsons-7e90b.firebaseapp.com",
|
||||
databaseURL: "https://fhsons-7e90b.firebaseio.com",
|
||||
projectId: "fhsons-7e90b",
|
||||
storageBucket: "fhsons-7e90b.appspot.com",
|
||||
messagingSenderId: "928837712391"
|
||||
});
|
||||
const db = firebase.firestore();
|
||||
|
||||
const components = JSON.parse(fs.readFileSync('./components.json').toString()).map(c => Object.assign(c, {createdOn: new Date(c.createdOn)}));
|
||||
|
||||
components.forEach(async (comp, i) => {
|
||||
await db.collection('components').doc(comp.name).set(comp);
|
||||
console.log(`${i + 1}/${components.length}`);
|
||||
});
|
||||
})();
|
23
src/uploader/FormulaUploader.js
Normal file
23
src/uploader/FormulaUploader.js
Normal file
@ -0,0 +1,23 @@
|
||||
const fs = require('fs');
|
||||
const firebase = require('firebase');
|
||||
|
||||
(function() {
|
||||
firebase.initializeApp({
|
||||
apiKey: "AIzaSyC7BFq-px3_XBC4VbV5noRDB4yK2Gfvz24",
|
||||
authDomain: "fhsons-7e90b.firebaseapp.com",
|
||||
databaseURL: "https://fhsons-7e90b.firebaseio.com",
|
||||
projectId: "fhsons-7e90b",
|
||||
storageBucket: "fhsons-7e90b.appspot.com",
|
||||
messagingSenderId: "928837712391"
|
||||
});
|
||||
const db = firebase.firestore();
|
||||
|
||||
const formulas = JSON.parse(fs.readFileSync('./formulas.json').toString()).map(f => Object.assign(f, {createdOn: new Date(f.createdOn), approvedOn: new Date(f.approvedOn)}));
|
||||
|
||||
formulas.forEach(async (formula, i) => {
|
||||
await db.collection('formulas').doc(formula.name).set(formula);
|
||||
console.log(`${i + 1}/${formulas.length}`)
|
||||
});
|
||||
})();
|
||||
|
||||
|
17
src/uploader/components.json
Normal file
17
src/uploader/components.json
Normal file
@ -0,0 +1,17 @@
|
||||
[
|
||||
{"name": "CT YELLOW", "description": "BASIC COLOUR", "price": 4.50, "createdOn": "Wed Mar 02 09:19:55 EST 2016"},
|
||||
{"name": "CT FL-BLUE", "description": "FLUORESCENT COLOUR", "price": 3.50, "createdOn": "Wed Mar 02 10:43:03 EST 2016"},
|
||||
{"name": "CT FL-YELLOW", "description": "FLUORESCENT COLOUR", "price": 5.00, "createdOn": "Wed Mar 02 10:42:06 EST 2016"},
|
||||
{"name": "CT FL-PURPLE", "description": "FLUORESCENT COLOUR", "price": 6.50, "createdOn": "Wed Mar 02 10:42:33 EST 2016"},
|
||||
{"name": "CT MARINE", "description": "BASIC COLOUR", "price": 4.00, "createdOn": "Wed Mar 02 10:40:21 EST 2016"},
|
||||
{"name": "CT RED", "description": "BASIC COLOUR", "price": 4.00, "createdOn": "Wed Mar 02 10:36:12 EST 2016"},
|
||||
{"name": "CT BLACK", "description": "BASIC COLOUR", "price": 3.00, "createdOn": "Wed Mar 02 10:29:36 EST 2016"},
|
||||
{"name": "CT GREEN", "description": "BASIC COLOUR", "price": 3.50, "createdOn": "Wed Mar 02 10:30:17 EST 2016"},
|
||||
{"name": "CT FL-RED", "description": "FLUORESCENT COLOUR", "price": 6.00, "createdOn": "Wed Mar 02 10:40:51 EST 2016"},
|
||||
{"name": "CT BLUE", "description": "BASIC COLOUR", "price": 3.50, "createdOn": "Wed Mar 02 10:29:57 EST 2016"},
|
||||
{"name": "CT VIOLET", "description": "BASIC COLOUR", "price": 6.00, "createdOn": "Wed Mar 02 09:57:09 EST 2016"},
|
||||
{"name": "CT FL-PINK", "description": "FLUORESCENT COLOUR", "price": 6.00, "createdOn": "Wed Mar 02 10:41:16 EST 2016"},
|
||||
{"name": "CT ORANGE", "description": "BASIC COLOUR", "price": 4.50, "createdOn": "Wed Mar 02 10:30:43 EST 2016"},
|
||||
{"name": "CT WHITE", "description": "BASIC COLOUR", "price": 3.50, "createdOn": "Wed Mar 02 09:19:21 EST 2016"},
|
||||
{"name": "CT MAGENTA", "description": "BASIC COLOUR", "price": 6.00, "createdOn": "Wed Mar 02 10:39:37 EST 2016"}
|
||||
]
|
1538
src/uploader/formulas.json
Normal file
1538
src/uploader/formulas.json
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user