Added auto cleanup on untouched open tasks if more the 30 are open.
This commit is contained in:
parent
cd96a95b68
commit
f807b03e74
1 changed files with 28 additions and 6 deletions
|
@ -270,6 +270,8 @@ class _taskManagerSingleton extends App.Controller
|
||||||
else
|
else
|
||||||
@showControllerHideOthers(params.key, params_app)
|
@showControllerHideOthers(params.key, params_app)
|
||||||
|
|
||||||
|
@tasksAutoCleanupDelay()
|
||||||
|
|
||||||
showControllerHideOthers: (thisKey, params_app) =>
|
showControllerHideOthers: (thisKey, params_app) =>
|
||||||
for key of @workers
|
for key of @workers
|
||||||
if key is thisKey
|
if key is thisKey
|
||||||
|
@ -498,6 +500,26 @@ class _taskManagerSingleton extends App.Controller
|
||||||
return if !task.id
|
return if !task.id
|
||||||
App.Taskbar.destroy(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: =>
|
tasksInitial: =>
|
||||||
@init()
|
@init()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue