 TaskFiles = require '../collections/TaskFiles'
 TaskCleanups = require '../collections/TaskCleanups'
 Deploys = require '../collections/Deploys'
-RequestHistoricalTasks = require '../collections/RequestHistoricalTasks'
+DeployDetails = require '../models/DeployDetails'
 Alerts = require '../collections/Alerts'
 
 FileBrowserSubview = require '../views/fileBrowserSubview'

                @fetchResourceUsage() if @models.task.get('isStillRunning')
            .success =>
                requestId = @models.task.attributes.task.taskRequest.request.id
                taskHistory = new RequestHistoricalTasks [], {requestId}
                taskHistory.fetch().success =>
                    alerts = @getAlerts taskHistory
                    @collections.alerts.reset()
                    for alert in alerts
                        @collections.alerts.add alert

                app.caughtError()
                delete @models.resourceUsage

    getAlerts: (deployInfo) =>
        task = @models.task
        alerts = []
        # Is this a scheduled task that has been running much longer than previous ones?
        if task.attributes.task.taskRequest.request.requestType == 'SCHEDULED' and task.get('isStillRunning')
            avg = deployInfo.get('deployStatistics')?.averageRuntimeMillis
            current =  new Date().getTime() - task.get('task').taskId.startedAt
            # Alert if current uptime is longer than twice the average
            if current > (avg * 2)
