Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions backend/services/service.jobs.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@ historyDbFn = () ->
whereInterval = "now_utc() - started <= interval '#{_interval}'"
dbquery = dbquery.whereRaw(whereInterval)

if query.name == 'All'
delete query.name
delete query.current # 'all' implies both current and non-current sets, so remove from query totally

if query.list?
if query.list == 'true'
dbquery = dbquery.select('name', 'current').groupBy('name', 'current')
dbquery = dbquery
.select(dbs.get('main').raw('DISTINCT ON (name) name'), 'current')
.groupBy('name', 'current')
.orderBy('name')
.orderBy('current', 'DESC')
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid duplicating tasks in the dropdown -- we want to see each task once, grouped by whether there is or is not a "current" version in the history

delete query.list

dbquery.where(query)
Expand Down
4 changes: 2 additions & 2 deletions frontend/admin/html/views/jobs/jobsCurrent.jade
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.btn.btn-primary(ng-click="loadCurrent()") Refresh
.summary-grid(cg-busy="summaryBusy" ui-grid="summaryGrid" ui-grid-resize-columns ui-grid-auto-resize ui-grid-pinning)
.btn.btn-primary(ng-click="loadSummary()") Refresh
.summary-grid.clickable-rows(cg-busy="summaryBusy" ui-grid="summaryGrid" ui-grid-resize-columns ui-grid-auto-resize ui-grid-pinning ui-grid-selection)
.jobs-grid(cg-busy="jobsBusy" ui-grid="jobsGrid" ui-grid-resize-columns ui-grid-auto-resize ui-grid-pinning)
12 changes: 9 additions & 3 deletions frontend/admin/html/views/jobs/jobsHistory.jade
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
.row.form-group
.col-md-2
select(ng-model="currentTaskData.task" ng-options="value.name group by (value.name=='All'?'All':value.current?'Current':'Not Current') for value in currentJobList track by value.selectid" ng-change="selectJob()")
select(ng-model="currentTaskData.task" ng-options="value.name group by (value.name=='All Tasks'?'All':value.current?'Current':'Not Current') for value in currentJobList track by value.name" ng-change="selectJob()")
option(value="" disabled) Select a task
option(value="") All
.col-md-2
select(type="text" ng-model="historyTimerange" ng-change="updateTimeframe()")
option(value="1 hour") 1 Hour
Expand All @@ -24,10 +23,17 @@
.row(ng-show="$state.params.task")
.col-md-12
h4 Error History
.jobs-grid(cg-busy="errorJobsBusy" ng-show="$state.params.task" ui-grid="jobsErrorGrid" ui-grid-edit ui-grid-cellNav ui-grid-resize-columns ui-grid-pinning)
.jobs-grid(cg-busy="errorJobsBusy" ng-show="$state.params.task" ui-grid="jobsErrorGrid" ui-grid-cellNav ui-grid-resize-columns ui-grid-pinning)
.row
.col-md-12.center(ng-show="$state.params.task")
div Showing {{jobsErrorGrid.data.length}} Results

.row(ng-show="$state.params.task && clickedCellInfo")
.col-md-12
h4 Full {{clickedCellInfo.name}} (selected cell)
.row
.col-md-12
pre {{clickedCellInfo.contents}}

.warn(ng-show="!$state.params.task") No task selected.

1 change: 1 addition & 0 deletions frontend/admin/scripts/app.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ app = window.angular.module appName, [
'ui.grid.autoResize'
'ui.grid.pinning'
'ui.grid.cellNav'
'ui.grid.selection'
]

module.exports = app
56 changes: 41 additions & 15 deletions frontend/admin/scripts/controllers/jobs/jobsCurrent.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ app.controller 'rmapsJobsCurrentCtrl',
footerCellTemplate: '<div class="numberCell">{{ col.getAggregationValue() }}</div>'

dateFilter = 'date:"MM/dd HH:mm"'
timeframeFilterMap =
"Current": { current: true }
"Last Hour": { timerange: "1 hour" }
"Last Day": { timerange: "1 day" }
"Last 7 Days": { timerange: "7 days" }
"Last 30 Days": { timerange: "30 days" }

$scope.jobsGrid =
enableColumnMenus: false
Expand All @@ -21,10 +27,8 @@ app.controller 'rmapsJobsCurrentCtrl',
field: 'name'
displayName: 'Task'
width: 100
cellTemplate: '<div class="ui-grid-cell-contents"><a ui-sref="jobsHistory({ task: \'{{COL_FIELD}}\' })">{{COL_FIELD}}</a></div>'
cellTemplate: '<div class="ui-grid-cell-contents"><a ui-sref="jobsHistory({ task: COL_FIELD })">{{COL_FIELD}}</a></div>'
footerCellTemplate: '<div>Totals</div>'
sort:
direction: uiGridConstants.ASC
pinnedLeft: true
,
field: 'status'
Expand All @@ -40,6 +44,8 @@ app.controller 'rmapsJobsCurrentCtrl',
type: 'date'
width: 100
cellFilter: dateFilter
sort:
direction: uiGridConstants.DESC
,
field: 'finished'
displayName: 'Finished'
Expand Down Expand Up @@ -105,9 +111,29 @@ app.controller 'rmapsJobsCurrentCtrl',
_.extend num, numericDefaults


$scope.currentFilters = null
$scope.summaryGrid =
enableColumnMenus: false
enablePinning: true
enableRowSelection: true
enableRowHeaderSelection: false
multiSelect: false
modifierKeysToMultiSelect: false
noUnselect: true
enableSelectionBatchEvent: false
onRegisterApi: (gridApi) ->
gridApi.selection.on.rowSelectionChanged $scope, (row) ->
if !row.isSelected
return
$scope.currentFilters =
queryFilters: timeframeFilterMap[row.entity.timeframe]
timeframe: row.entity.timeframe
$scope.loadCurrent()
gridApi.core.on.rowsRendered $scope, () ->
if !$scope.currentFilters?
gridApi.selection.selectRowByVisibleIndex(0)
else
gridApi.selection.selectRow(_.find($scope.summaryGrid.data, timeframe: $scope.currentFilters.timeframe))
columnDefs: [
field: 'timeframe'
pinnedLeft: true
Expand All @@ -124,7 +150,6 @@ app.controller 'rmapsJobsCurrentCtrl',
,
field: 'canceled'
]
rowTemplate: '<div ng-class="{\'summary-current\': row.entity.timeframe==\'Current\'}" ng-click="grid.appScope.fnOne(row)" ng-repeat="col in colContainer.renderedColumns track by col.colDef.name" class="ui-grid-cell" ui-grid-cell></div>'

# makes a map (object) of keys from list "grouping", values initialized to 'init'
emptyDatum = (grouping, init=0) ->
Expand All @@ -138,15 +163,7 @@ app.controller 'rmapsJobsCurrentCtrl',
init = emptyDatum(dimensionValues, init)
return init

$scope.loadCurrent = () ->
$scope.jobsBusy = rmapsJobsService.getHistory(current: true)
.then (jobs) ->
_.each jobs, (job) ->
job.started = new Date(job.started)
job.finished = new Date(job.finished)
job.status_changed = new Date(job.status_changed)
$scope.jobsGrid.data = jobs.plain()

$scope.loadSummary = () ->
$scope.summaryBusy = rmapsJobsService.getSummary()
.then (summary) ->
data = summary.plain()
Expand All @@ -173,7 +190,7 @@ app.controller 'rmapsJobsCurrentCtrl',
for d in data when d[dimension1] in showTimeframes and d[dimension2] in showStatus
summaryObj[d[dimension1]][d[dimension2]] = d.count

# Not a terribly efficient cummulative sum implementation, but dataset isn't going to be large here.
# Not a terribly efficient cumulative sum implementation, but dataset isn't going to be large here.
# At least order in dataObj shouldn't matter, and will simply return if no need to build sum
cSum = (dataObj, timeframe, status) ->
thisCount = parseInt(dataObj[timeframe][status])
Expand All @@ -198,5 +215,14 @@ app.controller 'rmapsJobsCurrentCtrl',

$scope.summaryGrid.data = summaryTable

$scope.loadCurrent = () ->
$scope.jobsBusy = rmapsJobsService.getHistory($scope.currentFilters.queryFilters)
.then (jobs) ->
_.each jobs, (job) ->
job.started = new Date(job.started)
job.finished = new Date(job.finished)
job.status_changed = new Date(job.status_changed)
$scope.jobsGrid.data = jobs.plain()

$rootScope.registerScopeData () ->
$scope.loadCurrent()
$scope.loadSummary()
52 changes: 29 additions & 23 deletions frontend/admin/scripts/controllers/jobs/jobsHistory.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ app.controller 'rmapsJobsHistoryCtrl',
task: null

$scope.currentJobList = []

$scope.historyTimerange = '30 days'
$scope.clickedCellInfo = null

numericDefaults =
type: 'number'
Expand Down Expand Up @@ -110,82 +110,88 @@ app.controller 'rmapsJobsHistoryCtrl',
$scope.jobsErrorGrid =
enableColumnMenus: false
enablePinning: true
enableCellEditOnFocus: true
appScopeProvider: $scope
onRegisterApi: (gridApi) ->
gridApi.cellNav.on.navigate $scope, (newRowCol, oldRowCol) ->
$scope.showFullCellContents(newRowCol)
columnDefs: [
field: 'task_name'
displayName: 'Task'
width: 100
pinnedLeft: true
enableCellEdit: false
,
field: 'name'
displayName: 'Subtask'
width: 150
pinnedLeft: true
enableCellEdit: false
,
field: 'status'
displayName: 'Status'
width: 75
enableCellEdit: false
,
field: 'retry_num'
displayName: 'Retries'
width: 75
enableCellEdit: false
,
field: 'batch_id'
displayName: 'Batch'
width: 75
enableCellEdit: false
,
field: 'started'
displayName: 'Started'
type: 'date'
width: 100
cellFilter: dateFilter
enableCellEdit: false
sort:
direction: uiGridConstants.DESC
,
field: 'finished'
displayName: 'Finished'
type: 'date'
width: 100,
cellFilter: dateFilter
enableCellEdit: false
,
field: 'data'
displayName: 'Data'
cellTemplate: '<div class="ui-grid-cell-contents">{{COL_FIELD | json}}</div>'
enableCellEdit: false
cellTemplate: '<div class="ui-grid-cell-contents clickable-cell">{{COL_FIELD | json}}</div>'
,
field: 'error'
displayName: 'error'
displayName: 'Error'
cellClass: 'clickable-cell'
,
field: 'stack'
displayName: 'Stack'
cellClass: 'clickable-cell'
]

$scope.tooltip = (mouseEvent) ->
console.log mouseEvent
$scope.showFullCellContents = (rowCol) ->
if !rowCol? || rowCol.col.colDef.displayName not in ['Data', 'Error', 'Stack']
$scope.clickedCellInfo = null
return
$scope.clickedCellInfo =
name: rowCol.col.colDef.displayName
contents: rowCol.row.entity[rowCol.col.colDef.name]
if $scope.clickedCellInfo.name == 'Data'
$scope.clickedCellInfo.contents = JSON.stringify($scope.clickedCellInfo.contents, null, 2)

$scope.updateTimeframe = () ->
if $scope.currentTaskData.task?
$scope.jobsGrid.data = []
$scope.jobsErrorGrid.data = []
$scope.currentTaskData.task = null
$scope.selectJob()
if $state.params.timerange # don't honor timerange parameter anymore
delete $state.params.timerange
$scope.loadReadyHistory()

$scope.selectJob = () ->
$state.go($state.current, { task: $scope.currentTaskData.task.name, current: $scope.currentTaskData.task.current, timerange: $scope.historyTimerange }, { reload: true })
filters =
timerange: $scope.historyTimerange
task: $scope.currentTaskData.task.name
$state.go($state.current, filters, { reload: true })

$scope.loadHistory = (task) ->
filters =
timerange: $scope.historyTimerange
errorFilters = _.clone filters
filters.current = task.current
if task.name != 'all'
if task.name != 'All Tasks'
filters.name = errorFilters.task_name = task.name

$scope.jobsBusy = rmapsJobsService.getHistory(filters)
Expand All @@ -202,7 +208,7 @@ app.controller 'rmapsJobsHistoryCtrl',
timerange: $scope.historyTimerange
$scope.jobsBusy = rmapsJobsService.getHistory(filters)
.then (currentJobList) ->
$scope.currentJobList = [{name: 'All', current: false}].concat currentJobList.plain()
$scope.currentJobList = [{name: 'All Tasks'}].concat currentJobList.plain()
for e, i in $scope.currentJobList
$scope.currentJobList[i].selectid = i

Expand All @@ -211,8 +217,8 @@ app.controller 'rmapsJobsHistoryCtrl',
.then () ->
if $state.params.timerange
$scope.historyTimerange = $state.params.timerange
if $state.params.task and $state.params.current
$scope.currentTaskData.task = _.find $scope.currentJobList, { name: $state.params.task, current: $state.params.current=='true' }
if $state.params.task
$scope.currentTaskData.task = _.find $scope.currentJobList, { name: $state.params.task }
if $scope.currentTaskData.task? # load history only if it's in our currentJobList dropdown (wouldn't have history entries for given filters)
$scope.loadHistory($scope.currentTaskData.task)
else # account for a certain case where a previous search was done, but new timerange selected that invalidates it since dropdown is refreshed, but $state.params remain
Expand Down
4 changes: 4 additions & 0 deletions frontend/admin/scripts/controllers/jobs/jobsQueue.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,28 @@ app.controller 'rmapsJobsQueueCtrl', ($scope, $log, $rootScope, $injector, Resta
type: 'number'
width: 175
defaultValue: 1
cellClass: 'clickable-cell'
,
field: 'subtasks_per_process'
displayName: 'Subtasks Per Process'
type: 'number'
width: 175
defaultValue: 1
cellClass: 'clickable-cell'
,
field: 'priority_factor'
displayName: 'Priority Factor'
type: 'number'
width: 150
defaultValue: 1.0
cellClass: 'clickable-cell'
,
field: 'active'
displayName: 'Active'
type: 'boolean'
width: 150
defaultValue: false
cellClass: 'clickable-cell'
]

new rmapsGridFactory($scope)
Loading