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
|
@ -193,13 +193,13 @@ class _taskManagerSingleton extends App.Controller
|
|||
if !task && !@workers[params.key] && !params.persistent
|
||||
task = new App.Taskbar
|
||||
task.load(
|
||||
key: params.key
|
||||
params: params.params
|
||||
callback: params.controller
|
||||
key: params.key
|
||||
params: params.params
|
||||
callback: params.controller
|
||||
client_id: 123
|
||||
prio: @newPrio()
|
||||
notify: false
|
||||
active: params.show
|
||||
prio: @newPrio()
|
||||
notify: false
|
||||
active: params.show
|
||||
)
|
||||
@allTasksByKey[params.key] = task.attributes()
|
||||
|
||||
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in a new issue