Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getPatchIndex(startTime) {
const date = new Date(startTime * 1000);
let i;
for (i = 1; i < constants.patch.length; i += 1) {
const pd = new Date(constants.patch[i].date);
// stop when patch date is past the start time
if (pd > date) {
break;
}
}
// use the value of i before the break, started at 1 to avoid negative index
return i - 1;
}
function getPatchIndex(startTime) {
const date = new Date(startTime * 1000);
let i;
for (i = 1; i < constants.patch.length; i += 1) {
const pd = new Date(constants.patch[i].date);
// stop when patch date is past the start time
if (pd > date) {
break;
}
}
// use the value of i before the break, started at 1 to avoid negative index
return i - 1;
}
async.eachSeries(matchIds, (match, cb) => {
console.log(match.match_id);
queries.upsert(
db, 'match_patch',
{
match_id: match.match_id,
patch: constants.patch[utility.getPatchIndex(match.start_time)].name,
},
{
match_id: match.match_id,
}, cb,
);
}, (err) => {
process.exit(Number(err));
async.eachSeries(matchIds, (match, cb) => {
queries.upsert(
db, 'match_patch',
{
match_id: match.match_id,
patch: constants.patch[utility.getPatchIndex(match.start_time)].name,
},
{
match_id: match.match_id,
}, cb,
);
}, (err) => {
console.error(err);
function upsertMatchPatch(cb) {
if (match.start_time) {
return upsert(trx, 'match_patch', {
match_id: match.match_id,
patch: constants.patch[utility.getPatchIndex(match.start_time)].name,
}, {
match_id: match.match_id,
}, cb);
}
return cb();
}
function upsertMatchPatch(cb) {
if (match.start_time) {
return upsert(trx, 'match_patch', {
match_id: match.match_id,
patch: constants.patch[utility.getPatchIndex(match.start_time)].name,
}, {
match_id: match.match_id,
}, cb);
}
return cb();
}