-
Notifications
You must be signed in to change notification settings - Fork 22
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
Feature/excel file import #198
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -226,7 +226,6 @@ module.exports = function(ReportModel) { | |
cb(error); | ||
}); | ||
|
||
cb(null); | ||
}); | ||
} | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function(StoreMappingModel) { | ||
|
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "StoreMappingModel", | ||
"base": "PersistedModel", | ||
"idInjection": true, | ||
"options": { | ||
"validateUpsert": true | ||
}, | ||
"properties": {}, | ||
"validations": [], | ||
"relations": {}, | ||
"acls": [], | ||
"methods": {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,9 @@ | |
"supertest-as-promised": "2.0.1", | ||
"underscore": "^1.7.0", | ||
"vend-nodejs-sdk": "^1.0.13", | ||
"winston": "^0.8.3" | ||
"winston": "^0.8.3", | ||
"xlsx": "~0.8.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use absolute version numbers, it help lock things down and keep them predictable |
||
"excel-stream": "~1.1.1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use absolute version numbers, it help lock things down and keep them predictable |
||
}, | ||
"optionalDependencies": { | ||
"loopback-explorer": "^1.1.0" | ||
|
@@ -50,7 +52,7 @@ | |
"grunt-karma": "~0.6.2", | ||
"grunt-localtunnel-me": "^0.1.1", | ||
"grunt-loopback-sdk-angular": "^1.1.2", | ||
"grunt-mustache-render":"1.9.2", | ||
"grunt-mustache-render": "1.9.2", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this required? |
||
"grunt-ngmin": "~0.0.3", | ||
"grunt-open": "~0.2.3", | ||
"grunt-protractor-runner": "~0.2.4", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
'use strict'; | ||
|
||
var debug = require('debug')('boot:create-store-mappings'); | ||
|
||
var Promise = require('bluebird'); | ||
var _ = require('underscore'); | ||
|
||
|
||
module.exports = createStoreMappings; | ||
|
||
function createStoreMappings(app,cb){ | ||
var StoreModel = app.models.StoreModel; | ||
var StoreMappingModel = app.models.StoreMappingModel; | ||
|
||
var seed = null; | ||
try { | ||
seed = require('./seed.json'); | ||
if(process.env.SKIP_SEEDING) { | ||
debug('Will skip the database seeding process'); | ||
return; | ||
} | ||
} catch (err) { | ||
debug('Please configure your data in `seed.json`.'); | ||
debug('Copy `seed.json.template` to `seed.json` and replace the values with your own.'); | ||
cb(err); | ||
} | ||
if(seed){ | ||
debug('seed each store-mapping, one-by-one'); | ||
return Promise.map( | ||
seed.storeConfigModels, | ||
function (storeData) { | ||
|
||
return Promise.map( | ||
storeData.storeMappingModels, | ||
function(oneMapping){ | ||
return StoreMappingModel.findOrCreate( | ||
{where:{code:oneMapping.code}}, | ||
oneMapping | ||
) | ||
.spread(function(mappingModelInstance,created){ | ||
(created) ? debug('mapping created', 'StoreMappingModel', mappingModelInstance) | ||
: debug('mapping found', 'StoreMappingModel', mappingModelInstance); | ||
}); | ||
}, | ||
{concurrency:1} | ||
) | ||
}, | ||
{concurrency:1} | ||
) | ||
.then(function(){ | ||
debug('Done with seeding mappings'); | ||
cb(); | ||
}) | ||
.catch(function(err){ | ||
log.error('error',err); | ||
cb(err); | ||
}); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shame on me!