23 lines
593 B
JavaScript
23 lines
593 B
JavaScript
|
'use strict';
|
||
|
const path = require('path');
|
||
|
const app = require(path.resolve(__dirname, '../server'));
|
||
|
const argv = require('minimist')(process.argv.slice(2));
|
||
|
const _ = require('lodash');
|
||
|
const Promise = require('bluebird');
|
||
|
|
||
|
app.models.Elu.find({ where: { mandat: 'Maire', party: 'unknown' } })
|
||
|
.then(function(elus){
|
||
|
return Promise.map(elus, function(elu){
|
||
|
return app.models.EluDataScraper.getDataForElu(elu)
|
||
|
.then(eluData => {
|
||
|
elu.party = eluData.party;
|
||
|
return elu.save();
|
||
|
})
|
||
|
}, { concurrency: 10 });
|
||
|
})
|
||
|
.then(function(){
|
||
|
console.log('Done.');
|
||
|
process.exit();
|
||
|
});
|
||
|
|