Added auto cleanup on untouched open tasks if more the 30 are open.

This commit is contained in:
Martin Edenhofer 2016-07-14 19:24:13 +02:00
parent cd96a95b68
commit f807b03e74

View file

@ -270,6 +270,8 @@ class _taskManagerSingleton extends App.Controller
else
@showControllerHideOthers(params.key, params_app)
@tasksAutoCleanupDelay()
showControllerHideOthers: (thisKey, params_app) =>
for key of @workers
if key is thisKey
@ -498,6 +500,26 @@ class _taskManagerSingleton extends App.Controller
return if !task.id
App.Taskbar.destroy(task.id)
tasksAutoCleanupDelay: =>
delay = =>
@tasksAutoCleanup()
App.Delay.set(delay, 10000, 'task-autocleanup')
tasksAutoCleanup: =>
# auto cleanup of old tasks
currentTaskCount = =>
Object.keys(@allTasksByKey).length
maxTaskCount = 30
if currentTaskCount() > maxTaskCount
for task in App.Taskbar.search(sortBy:'updated_at', order:'ASC')
if currentTaskCount() > maxTaskCount
if !task.active
if _.isEmpty(task.state) || (_.isEmpty(task.state.ticket) && _.isEmpty(task.state.article))
@log 'notice', "More then #{maxTaskCount} tasks open, close oldest untouched task #{task.key}"
@remove(task.key)
tasksInitial: =>
@init()