Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if(typeof options[i] != 'string')
continue;
var pseuroArray = options[i].match(/^\[([^\]]*)\]$/);
console.log(options[i],'rrrrr', pseuroArray)
if(!pseuroArray)
continue;
options[i] = _.map(pseuroArray[1].split(','), function(d) {
if(isNaN(d))
return d.trim();
else
return +d;
});
}
console.log(clc.blackBright(' executing query: ', clc.magentaBright(options.cypher), '...\n'));
// enrich options with timestamp (always useful though)
if(!options.exec_time || !options.exec_date){
var now = require('../../helpers').now();
options.exec_time = now.time;
options.exec_date = now.date;
}
query = (options.profile? 'PROFILE ':'') + parser.agentBrown(queries[path[1]], options);
console.log(query)
console.log('with params')
console.log(options)
var q = async.queue(function (triplet, nextTriplet) {
console.log(clc.blackBright("processing id =", clc.whiteBright(triplet.id), triplet.doi, "remaining", clc.magentaBright(q.length(), loops-n, total_count)));
var contentToIndex = _.compact(_.unique(_.values(triplet.translations))).join(' ').toLowerCase();
if(!contentToIndex.length) {
contentToIndex = _.compact(_.values(triplet.archive)).join(' ').toLowerCase();
}
if(!contentToIndex.length) {
console.log(triplet.translations)
throw 'not enough content'
}
contentToIndex = _.compact([ triplet.doi, contentToIndex, helpers.text.translit(contentToIndex)]).join(' ');// + ' ' + helpers.text.translit(contentToIndex);
neo4j.query(''+
' MATCH (res:resource) '+
' WHERE id(res) = {id} SET res.full_search = {full_search} RETURN res', {
id: triplet.id,
full_search: S(contentToIndex).stripTags().s
}, function (err, n) {
// nodes only to be updated
toBeUpdated = _.flatten(groups.filter(function (d) {
return d.length == 1
}));
// nodes to be merged
toBeMerged = groups.filter(function (d) {
return d.length > 1
});
// remove groups from memory (we creaed a copy)
delete groups
// output to the user
console.log(clc.blackBright(' to be updated:', clc.magentaBright(toBeUpdated.length), '- to be merged:',clc.magentaBright(_.sum(toBeMerged, function (d) {return d.length})), 'nodes, in', clc.magentaBright(toBeMerged.length)));
// first things first: update what need to be updated, with user confirmation
var checkNodes = [];
async.series([
function merge(next) {
var q = async.queue(function (group, nextGroup) {
var ids = _.map(group, function (d) {return +d.id}),
names = _.map(group, 'name');
console.log(clc.blackBright('\n merging nodes:', clc.cyanBright(JSON.stringify(ids)), 'remaining:'),q.length());
// collect all the relationships for the nodes
neo4j.query('MATCH (n) WHERE id(n) in {ids} WITH n MATCH p=(n)-[r]-(t) RETURN n as node, r as rel', {
ids: ids
}, function (err, tuples) {
if(err) {
create: function(options, callback) {
var User = require('../../models/user');
console.log(clc.yellowBright('\n tasks.helpers.staffpick.create'));
console.log(clc.blackBright(' generating user'), clc.magentaBright('MARVIN (staffpick)'));
User.create({
username : 'MARVIN-staff',
password : 'marvin',
email : 'marvin staffpick',
firstname : 'MARVIN',
lastame : 'marvin',
strategy : 'local', // the strategy passport who creates his account, like local or google or twitter
about : '',
status : 'enabled',
picture : 'https://upload.wikimedia.org/wikipedia/en/c/cb/Marvin_%28HHGG%29.jpg'
}, function (err, user) {
if(err)
callback(null, _.assign(options, {
username: 'MARVIN-staff',
}));
else {
User.create(generator.user.marvin(), function (err, user) {
if(err)
callback(err)
else {
console.log(clc.blackBright(' user', clc.magentaBright('MARVIN'), 'generated'));
callback(null, _.assign(options, {
marvin: _.assign(user, {
pwd: generator.user.marvin().password // its password, before it is encrypted
})
}));
}
});
}
}, function (err, data) {
if(err) {
callback(err);
return;
}
console.log(clc.blackBright(' parsing csv file completed,', clc.magentaBright(data.length), 'records found'));
console.log(clc.blackBright(' e.g:'), _.take(data,2));
options.data = data;
callback(null, options);
});
}
public static debug (message: any, context: string|Record = '', isTimeDiffEnabled = true) {
this.printMessage(message, clc.magentaBright, context, isTimeDiffEnabled);
}
fn: (str) => clicolor.magentaBright(str).replace(/<%m(.+)>/g, '$1')
});
var result = profile.username + '@' + profile.host;
var opts = [];
if (profile.identity) {
opts.push('using identity');
}
if (profile.password) {
opts.push('using password');
}
if (!profile.password && typeof profile.password !== 'undefined') {
opts.push('using interactive password');
}
if (opts.length) {
result = result + ' (' + opts.join(', ') + ')';
}
if (profile.default) {
result = result + ' ' + C.magentaBright('[default]');
}
return result;
};