feat: remove all instances of moment usage
This commit is contained in:
parent
7d6fb17158
commit
973040f409
29 changed files with 252 additions and 193 deletions
|
|
@ -1,11 +1,11 @@
|
|||
const _ = require('lodash/fp')
|
||||
const moment = require('moment')
|
||||
|
||||
const ticker = require('../ticker')
|
||||
const settingsLoader = require('./settings-loader')
|
||||
|
||||
const db = require('../db')
|
||||
const machineLoader = require('../machine-loader')
|
||||
const { intervalToDuration, secondsToMilliseconds, formatDuration } = require('date-fns')
|
||||
|
||||
const CONSIDERED_UP_SECS = 30
|
||||
|
||||
|
|
@ -37,8 +37,8 @@ function machinesLastPing () {
|
|||
|
||||
if (downRows.length === 1) {
|
||||
const row = downRows[0]
|
||||
const age = moment.duration(row.age, 'seconds')
|
||||
return `${row.name} down for ${age.humanize()}`
|
||||
const age = intervalToDuration({ start: 0, end: secondsToMilliseconds(row.age) })
|
||||
return `${row.name} down for ${formatDuration(age)}`
|
||||
}
|
||||
|
||||
return 'Multiple machines down'
|
||||
|
|
@ -54,9 +54,9 @@ function status () {
|
|||
|
||||
return Promise.all([checkWasConfigured(), db.oneOrNone(sql, ['ping']), machinesLastPing()])
|
||||
.then(([wasConfigured, statusRow, machineStatus]) => {
|
||||
const age = statusRow && moment.duration(statusRow.age, 'seconds')
|
||||
const age = statusRow && intervalToDuration({ start: 0, end: secondsToMilliseconds(statusRow.age) })
|
||||
const up = statusRow ? statusRow.age < CONSIDERED_UP_SECS : false
|
||||
const lastPing = statusRow && age.humanize()
|
||||
const lastPing = statusRow && formatDuration(age)
|
||||
|
||||
return settingsLoader.loadLatest()
|
||||
.catch(() => null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue