Show duration of previous task run in admin panel.

See: https://github.com/freifunkhamburg/ffffng/issues/29
This commit is contained in:
baldo 2017-05-13 12:08:16 +02:00
parent 3ad8eeffa2
commit 05c6cdafb7
3 changed files with 12 additions and 2 deletions
server

View file

@ -38,6 +38,7 @@ angular.module('ffffng').factory('Scheduler', function ($injector, Logger, confi
job: job,
runningSince: false,
lastRunStarted: false,
lastRunDuration: null,
state: 'idle',
enabled: true
};
@ -54,8 +55,11 @@ angular.module('ffffng').factory('Scheduler', function ($injector, Logger, confi
job.run(function () {
var now = moment();
Logger.tag('jobs').profile('[%sms]\t%s', now.diff(task.runningSince), task.name);
var duration = now.diff(task.runningSince);
Logger.tag('jobs').profile('[%sms]\t%s', duration, task.name);
task.runningSince = false;
task.lastRunDuration = duration;
task.state = 'idle';
});
};

View file

@ -19,6 +19,7 @@ angular.module('ffffng').factory('TaskResource', function (
schedule: task.schedule,
runningSince: task.runningSince && task.runningSince.unix(),
lastRunStarted: task.lastRunStarted && task.lastRunStarted.unix(),
lastRunDuration: task.lastRunDuration || undefined,
state: task.state,
enabled: task.enabled
};