added stale agent function

sig-changes^2
Joshua Collins 4 years ago
parent 79a948c939
commit f9d6aed78d
  1. 8
      app/store/agents.js
  2. 5
      package.json

@ -11,7 +11,7 @@ const Agents = () => {
agent.ip = ip
agent.profile = profile
agent.interval = parseInt(interval)
agent.last_beacon_date = new Date(Date.now()).toLocaleString()
agent.last_beacon_date = moment.utc().format('MM/DD/YYYY, hh:mm:SS A')
agent.status = true
obj.agents.push(agent)
return agent.id
@ -22,7 +22,7 @@ const Agents = () => {
if (!agent) {
return null
} else {
const lbd = moment(agent.last_beacon_date)
const lbd = moment(agent.last_beacon_date, 'MM DD YYYY, hh:mm:SS A')
const diff = (lbd.diff(moment(), 'second') * -1)
if (diff > agent.interval) {
agent.status = false
@ -34,7 +34,7 @@ const Agents = () => {
obj.updateAgentBeaconTime = (agentId) => {
obj.agents.forEach(a => {
if (a.id === agentId) {
a.last_beacon_date = new Date(Date.now()).toLocaleString()
a.last_beacon_date = moment.utc().format('MM/DD/YYYY, hh:mm:SS A')
return true
}
})
@ -63,7 +63,7 @@ const Agents = () => {
obj.getAllAgents = () => {
obj.agents.forEach(agent => {
const lbd = moment(agent.last_beacon_date)
const lbd = moment(agent.last_beacon_date, , 'MM DD YYYY, hh:mm:SS A')
const diff = (lbd.diff(moment(), 'second') * -1)
if (diff > agent.interval) {
agent.status = false

@ -15,11 +15,6 @@
"express": "^4.17.1",
"moment": "^2.27.0"
},
"devDependencies": {
"jest": "^26.4.0",
"nodemon": "^2.0.4",
"supertest": "^4.0.2"
},
"jest": {
"testEnvironment": "node",
"coveragePathIgnorePatterns": [

Loading…
Cancel
Save