[users at bb.net] build.complete always false?
Greg MacDonald
gmacdonald at trionworlds.com
Thu Feb 4 19:26:20 UTC 2016
Hi Pierre, Thanks for taking a look. I’ll update to beta 6 shortly. Seems like maybe an accessor isn’t working or something. The correct value is in the instance.
Edited console output:
build: BuildInstance { … complete: true …
build.complete: false
Here’s my code. It’s a status progress button that sums up the progress from several builders. Like all debug compile checks. Focus on the debug prints in onChange.
class _buildStatus extends Controller
constructor: ($scope, $attrs, dataService, $log, RESULTS, $interval) ->
$scope.builder = $attrs.builder
$scope.name = $attrs.name
$scope.status = 'unknown'
$scope.pvalue = 0
builders = $attrs.builders.split(',')
data = dataService.open().closeOnDestroy($scope)
estimates = {}
pending = {}
lastBuildResult = null
arePending = ->
for builderId, startedTimes of pending
for startedTime in startedTimes
return true
return false
filterOutliers = (someArray) ->
# Copy the values, rather than operating on references to existing values
values = someArray.concat()
# Then sort
values.sort (a, b) ->
a - b
### Then find a generous IQR. This is generous because if (values.length / 4)
# is not an int, then really you should average the two elements on either
# side to find q1.
###
q1 = values[Math.floor(values.length / 4)]
# Likewise for q3.
q3 = values[Math.ceil(values.length * 3 / 4)]
iqr = q3 - q1
# Then find min and max values
maxValue = q3 + iqr * 1.5
minValue = q1 - (iqr * 1.5)
# Then filter anything beyond or beneath these values.
values.filter((x) -> x <= maxValue and x >= minValue)
computeEstimate = ->
if not arePending()
return
totalElapsed = 0.0
totalBuildTimes = 0.0
nowTime = (Date.now() / 1000)
totalPending = 0
for builderId, startedTimes of pending
estimatedBuildTime = estimates[builderId]
if not estimatedBuildTime
return
for startedTime in startedTimes
totalPending += 1
elapsedTime = nowTime - startedTime
totalElapsed += elapsedTime
totalBuildTimes += estimates[builderId]
#$log.debug('totalPending: ' + totalPending)
#$log.debug('totalElapsedTime: ' + totalElapsed)
#$log.debug('totalBuildTimes: ' + totalBuildTimes)
$scope.pvalue = Math.min(100, Math.round((totalElapsed / totalBuildTimes) * 100))
#$log.debug('pvalue: ' + $scope.pvalue)
intervalPromise = null
updateState = ->
if intervalPromise != null
$interval.cancel(intervalPromise)
intervalPromise = null
if arePending()
$scope.status = 'active'
intervalPromise = $interval (->
computeEstimate()
), 1000, 0, true
else if lastBuildResult != null
if lastBuildResult != RESULTS.SUCCESS
$scope.status = 'failure'
else
$scope.status = 'success'
else
$scope.status = 'unknown'
for builder in builders
data.getBuilders(name: builder, limit:1).onNew = (builder) ->
builderBuildTimes = []
filteredBuilderBuildTimes = []
pending[builder.builderid] = []
xs = data.getBuilds(builderid: builder.builderId, complete: true, order: '-buildid', limit:500)
xs.onNew = (build) ->
builderBuildTimes.push(build.complete_at - build.started_at)
filteredBuilderBuildTimes = filterOutliers(builderBuildTimes)
if filteredBuilderBuildTimes.length > 0
averageBuildTime = (filteredBuilderBuildTimes.reduce (x, y) -> x + y) / filteredBuilderBuildTimes.length
estimates[builder.builderid] = averageBuildTime
ys = data.getBuilds(builderid: builder.builderid, order: '-buildid', complete: false)
ys.onNew = (build) ->
pending[builder.builderid].push(build.started_at)
updateState()
ys.onChange = (builds) ->
pending[builder.builderid] = []
for build in builds
$log.debug('build: ', build)
$log.debug('build.complete: ', build.complete)
if build.state_string == 'finished'
continue
pending[builder.builderid].push(build.started_at)
updateState()
zs = data.getBuilds(builderid: builder.builderId, order: '-buildid', limit:1)
zs.onNew = (build) ->
lastBuildResult = build.results
updateState()
zs.onChange = (builds) ->
for build in builds
lastBuildResult = build.results
updateState()
break
From: Pierre Tardy [mailto:tardyp at gmail.com]
Sent: Thursday, February 04, 2016 10:41 AM
To: Greg MacDonald; users at buildbot.net
Subject: Re: [users at bb.net] build.complete always false?
Hi Greg,
I think you should share your controller code in order for me to see how you use the data-module.
You should also probably update to beta6 as there as been a number of fixes in the data-module, and UI.
Le mer. 3 févr. 2016 à 20:37, Greg MacDonald <gmacdonald at trionworlds.com<mailto:gmacdonald at trionworlds.com>> a écrit :
Hi Everyone,
I’m having a strange problem with the complete property of a BuildInstance in coffeescript. I’ve registered for on change messages for a build collection, which works great. The only problem is, inside the onChange(build) method I’m always getting false for build.complete, but if I $log.debug the build object itself I can drill down and see that complete is set to true. Other members are fine, like build.number and build.state_string. typeof build.complete is a Boolean.
I’m running through the gulp proxy. And I’m running relatively recent code, I haven’t updated to beta 6 yet though. I’m not sure if that matters. Any ideas?
Thx.
-Greg
_______________________________________________
users mailing list
users at buildbot.net<mailto:users at buildbot.net>
https://lists.buildbot.net/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.buildbot.net/pipermail/users/attachments/20160204/0e3b1965/attachment.html>
More information about the users
mailing list