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
|
if !task && !@workers[params.key] && !params.persistent
|
||||||
task = new App.Taskbar
|
task = new App.Taskbar
|
||||||
task.load(
|
task.load(
|
||||||
key: params.key
|
key: params.key
|
||||||
params: params.params
|
params: params.params
|
||||||
callback: params.controller
|
callback: params.controller
|
||||||
client_id: 123
|
client_id: 123
|
||||||
prio: @newPrio()
|
prio: @newPrio()
|
||||||
notify: false
|
notify: false
|
||||||
active: params.show
|
active: params.show
|
||||||
)
|
)
|
||||||
@allTasksByKey[params.key] = task.attributes()
|
@allTasksByKey[params.key] = task.attributes()
|
||||||
|
|
||||||
|
@ -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