const elementColor = (logName === 'lando') ? 'lando' : 'app'; fcw = _.max([fcw, _.size(element)]);
if (_.max(_.values(urlCounts)) > 1) { app.log.error('You cannot assign url %s to more than one service!', _.findKey(urlCounts, c => c > 1));
function getNextId() { var maxId = _.max(tigers, function(tiger) { return tiger.id; }).id; return maxId + 1; }
messagesGet (id, maxMessages = this.historyMaxGetMessages) { if (maxMessages <= 0) { return Promise.resolve([]) } id = _.max([0, id]) return this.redis.messagesGet( this.makeKeyName('lastMessageId'), this.makeKeyName('historyMaxSize'), this.makeKeyName('messagesIds'), this.makeKeyName('messagesTimestamps'), this.makeKeyName('messagesHistory'), id, maxMessages) .spread((msgs, tss, ids) => { return this.convertMessages(msgs, tss, ids) }) }
function calculateDateRangeForStories(stories) { var timestamps = storiesToCompletedTimestamps(stories); var fromDate = _.min(timestamps); var toDate = _.max(timestamps); return createDateRange(fromDate, toDate); }
function calculateCycleTimeChartData(stories, dateRange) { var data = 'Data.CycleTimeChart = [\n'; var cycleTimes = []; _.each(dateRange, function (day) { _.each(stories, function (story) { if (story.completed_at.split('T')[0] === day) { var cycleTime = (new Date(story.completed_at).getTime() - new Date(story.started_at).getTime()) / MILLISECONDS_IN_A_DAY; cycleTimes.push(cycleTime); } }); if (day.split('-')[2] === '01') { data += ' [new Date("' + day + '"), ' + _.max(cycleTimes) + ', ' + _.mean(cycleTimes) + ', ' + _.min(cycleTimes) + '],\n'; cycleTimes = []; } }); data += '];\n'; return data; }
app.post('/users', function(req, res) { var userScheme = getUserScheme(req); if (!userScheme.username || !req.body.password) { return res.status(400).send("You must send the username and the password"); } if (_.find(users, userScheme.userSearch)) { return res.status(400).send("A user with that username already exists"); } var profile = _.pick(req.body, userScheme.type, 'password', 'extra'); profile.id = _.max(users, 'id').id + 1; users.push(profile); res.status(201).send({ id_token: createIdToken(profile), access_token: createAccessToken() }); });
_.max(_.map(keys, e => e.toString().length))
async backfill(exchangeName, symbol, period, date) { const exchange = this.exchangesIterator.find(e => e.getName() === exchangeName); if (!exchange) { throw `Exchange not found: ${exchangeName}`; } let start = moment().subtract(date, 'days'); let candles; do { console.log(`Since: ${new Date(start).toISOString()}`); candles = await exchange.backfill(symbol, period, start); const exchangeCandlesticks = candles.map(candle => { return ExchangeCandlestick.createFromCandle(exchangeName, symbol, period, candle); }); await this.candleImporter.insertCandles(exchangeCandlesticks); console.log(`Got: ${candles.length} candles`); start = _.max(candles.map(r => new Date(r.time * 1000))); } while (candles.length > 10); console.log('finish'); }
calcProbableValue(values) { let itemIndex while (values.length > 2) { const avg = _.mean(values) const min = _.min(values) const max = _.max(values) if ((min + max) / 2 === avg) { return avg } let maxDeviation = 0 _.forEach(values, (value, i) => { const deviation = Math.abs(value - avg) if (deviation > maxDeviation) { maxDeviation = deviation itemIndex = i } }) values.splice(itemIndex, 1) } return parseInt(_.mean(values)) }
messagesGet (id, maxMessages = this.historyMaxGetMessages) { if (maxMessages <= 0) { return Promise.resolve([]) } id = _.max([0, id]) const lastid = this.lastMessageId id = _.min([id, lastid]) const end = lastid - id const len = _.min([maxMessages, end]) const start = _.max([0, end - len]) const msgs = this.messagesHistory.slice(start, end) const tss = this.messagesTimestamps.slice(start, end) const ids = this.messagesIds.slice(start, end) const data = [] for (let idx = 0; idx < msgs.length; idx++) { const msg = msgs[idx] const obj = _.cloneDeep(msg) msg.timestamp = tss[idx] msg.id = ids[idx] data[idx] = obj } return Promise.resolve(msgs) }
res.swagger.lastModified = _.max(resources, "modifiedOn").modifiedOn;
app.post('/api/v1/users/register', function(req, res) { const userScheme = getUserScheme(req); if (!userScheme.username || !req.body.password) { return res.status(400).send({ error_message: 'You must send the username and the password' }); } if (_.find(users, userScheme.userSearch)) { return res.status(400).send({ error_message: 'A user with that username already exists' }); } const profile = _.pick(req.body, userScheme.type, 'password', 'extra'); profile.id = _.max(users, 'id').id + 1; users.push(profile); res.status(201).send({ error_message: null, token_id: createIdToken(profile) }); });