-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategory-insertion.js
40 lines (38 loc) · 1.31 KB
/
category-insertion.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const pratilipisToAdd = require('./json-data/added_categories');
const pratilipisToUpdate = require('./json-data/updated_categories');
const pratilipisToDelete = require('./json-data/deleted_categories');
var parameterStoreAccessor = require('./helpers/ParameterStoreAccessor');
var CategoryService;
function startInsertion() {
// CategoryService.updateNames(pratilipisToUpdate)
// CategoryService.addNewSystemCategories(pratilipisToAdd)
CategoryService.addNewSystemCategories(pratilipisToAdd)
.then(() => {
console.log('All categories successfully added.');
return CategoryService.updateNames(pratilipisToUpdate);
})
.then(() => {
console.log('All categories successfully updated.');
return CategoryService.markSystemCategoriesAsSuggested(pratilipisToDelete);
})
.then(() => {
console.log('All categories successfully deleted.');
process.exit();
})
.catch((err) => {
console.log(`[ERROR OCCURED] ${err}`);
process.exit();
})
;
}
parameterStoreAccessor.getMySqlDbCredentials()
.then(config => {
Object.assign(process.env, config);
var models = require('./sequelize-models');
CategoryService = require('./CategoryIngestionService');
return models.sequelize.authenticate();
})
.then(() => {
startInsertion();
})
;