I’m pretty sure there’s still a bug here. The client isn’t actually dropping the build. It’s appearing in the onChange collection after it’s been cancelled. If I log the entire build instance to the console and drill down I can see complete is true as expected. But logging build.complete returns false. But it shouldn’t be there at all anyway. If I didn’t have the status string I would have no way of removing it from the estimate.
From: Pierre Tardy [mailto:tar...@gmail.com] Sent: Thursday, February 04, 2016 11:54 AM To: Greg MacDonald; users@buildbot.net Subject: Re: [us...@bb.net] build.complete always false? ahah. I spent some time scratching my head.. ys = data.getBuilds(builderid: builder.builderid, order: '-buildid', complete: false) You have filter on your collection for complete==False This means that the server side will filter for complete builds, but this also means that the client side will drop your builds from the collection as soon as they are complete. So I believe this is a works as I expect (maybe not as you would expect :) ) Le jeu. 4 févr. 2016 à 20:26, Greg MacDonald <gmacdon...@trionworlds.com<mailto:gmacdon...@trionworlds.com>> a écrit : 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<http://scope.name> = $attrs.name<http://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:tar...@gmail.com<mailto:tar...@gmail.com>] Sent: Thursday, February 04, 2016 10:41 AM To: Greg MacDonald; users@buildbot.net<mailto:users@buildbot.net> Subject: Re: [us...@bb.net<mailto:us...@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 <gmacdon...@trionworlds.com<mailto:gmacdon...@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@buildbot.net<mailto:users@buildbot.net> https://lists.buildbot.net/mailman/listinfo/users
_______________________________________________ users mailing list users@buildbot.net https://lists.buildbot.net/mailman/listinfo/users