change status waiting to queued + other small fixes

This commit is contained in:
oleg 2015-05-05 00:28:59 +03:00
parent 01260c5a44
commit 424cae24c6
4 changed files with 20 additions and 16 deletions

View File

@ -86,7 +86,7 @@ Distributor.prototype.run = function(project, params, callback) {
self._updateBuild({ self._updateBuild({
project: project, project: project,
params: params, params: params,
status: 'waiting' status: 'queued'
}, this.slot()); }, this.slot());
}, },
function(err, build) { function(err, build) {

View File

@ -25,7 +25,7 @@ module.exports = function(app) {
nodes: [{type: 'local', maxExecutorsCount: 1}], nodes: [{type: 'local', maxExecutorsCount: 1}],
onBuildUpdate: function(build, callback) { onBuildUpdate: function(build, callback) {
var buildsResource = app.dataio.resource('builds'); var buildsResource = app.dataio.resource('builds');
if (build.status === 'waiting') { if (build.status === 'queued') {
build.id = ++buildsSequnce; build.id = ++buildsSequnce;
// create resource for build data // create resource for build data
var buildDataResource = app.dataio.resource('build' + build.id); var buildDataResource = app.dataio.resource('build' + build.id);
@ -34,7 +34,7 @@ module.exports = function(app) {
}); });
} }
buildsResource.clientEmitSync( buildsResource.clientEmitSync(
build.status === 'waiting' ? 'create' : 'update', build.status === 'queued' ? 'create' : 'update',
build build
); );
callback(null, build); callback(null, build);

View File

@ -7,17 +7,17 @@ define([
) { ) {
var connect = dataio(socketio.connect()); var connect = dataio(socketio.connect());
var projects = connect.resource('projects'), var projectsResource = connect.resource('projects'),
projectsTemplate = _($('#projects-template').html()).template(); projectsTemplate = _($('#projects-template').html()).template();
$('#projects').on('click', '.js-projects .js-run', function() { $('#projects').on('click', '.js-projects .js-run', function() {
var projectName = $(this).parent('.js-project').data('name'); var projectName = $(this).parent('.js-project').data('name');
projects.sync('run', {projectName: projectName}, function(err, result) { projectsResource.sync('run', {projectName: projectName}, function(err, result) {
$('#content').append(err && err.message); $('#content').append(err && err.message);
}); });
}); });
projects.sync('read', function(err, projects) { projectsResource.sync('read', function(err, projects) {
$('#projects').html( $('#projects').html(
(err && err.message) || (err && err.message) ||
projectsTemplate({projects: projects}) projectsTemplate({projects: projects})
@ -25,13 +25,13 @@ define([
}); });
var builds = connect.resource('builds'), var buildsResource = connect.resource('builds'),
buildsTemplate = _($('#builds-template').html()).template(), buildsTemplate = _($('#builds-template').html()).template(),
buildsHash = {}; builds = [];
$('#builds').on('click', '.js-builds .js-show-console', function() { $('#builds').on('click', '.js-builds .js-show-console', function() {
var buildId = $(this).parent('.js-build').data('id'), var buildId = $(this).parent('.js-build').data('id'),
resourceName = 'build' + buildId;; resourceName = 'build' + buildId;
$('#build-console').prev('h2').html('Build #' + buildId + ' console'); $('#build-console').prev('h2').html('Build #' + buildId + ' console');
$('#build-console').html(''); $('#build-console').html('');
@ -41,10 +41,14 @@ define([
}); });
}); });
builds.subscribe(function(build, action) { buildsResource.subscribe(function(build, action) {
buildsHash[build.id] = build; var oldBuild = _(builds).findWhere({id: build.id});
$('#builds').html(buildsTemplate({ if (oldBuild) {
builds: _(buildsHash).values().reverse() _(oldBuild).extend(build);
})); } else {
builds.unshift(build);
}
$('#builds').html(buildsTemplate({builds: builds}));
}); });
}); });

View File

@ -43,7 +43,7 @@ describe('Distributor', function() {
it('instance should be created without errors', function() { it('instance should be created without errors', function() {
var number = 1; var number = 1;
var conditionsHash = { var conditionsHash = {
1: {queue: {length: 0}, build: {status: 'waiting'}}, 1: {queue: {length: 0}, build: {status: 'queued'}},
2: {queue: {length: 1}, build: {status: 'in-progress'}}, 2: {queue: {length: 1}, build: {status: 'in-progress'}},
3: {queue: {length: 0}, build: {status: 'done'}}, 3: {queue: {length: 0}, build: {status: 'done'}},
4: 'Should never happend' 4: 'Should never happend'
@ -92,7 +92,7 @@ describe('Distributor', function() {
it('instance should be created without errors', function() { it('instance should be created without errors', function() {
var number = 1; var number = 1;
var conditionsHash = { var conditionsHash = {
1: {queue: {length: 0}, build: {status: 'waiting'}}, 1: {queue: {length: 0}, build: {status: 'queued'}},
2: {queue: {length: 1}, build: {status: 'in-progress'}}, 2: {queue: {length: 1}, build: {status: 'in-progress'}},
3: { 3: {
queue: {length: 0}, queue: {length: 0},