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({
project: project,
params: params,
status: 'waiting'
status: 'queued'
}, this.slot());
},
function(err, build) {

View File

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

View File

@ -7,17 +7,17 @@ define([
) {
var connect = dataio(socketio.connect());
var projects = connect.resource('projects'),
var projectsResource = connect.resource('projects'),
projectsTemplate = _($('#projects-template').html()).template();
$('#projects').on('click', '.js-projects .js-run', function() {
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);
});
});
projects.sync('read', function(err, projects) {
projectsResource.sync('read', function(err, projects) {
$('#projects').html(
(err && err.message) ||
projectsTemplate({projects: projects})
@ -25,13 +25,13 @@ define([
});
var builds = connect.resource('builds'),
var buildsResource = connect.resource('builds'),
buildsTemplate = _($('#builds-template').html()).template(),
buildsHash = {};
builds = [];
$('#builds').on('click', '.js-builds .js-show-console', function() {
var buildId = $(this).parent('.js-build').data('id'),
resourceName = 'build' + buildId;;
resourceName = 'build' + buildId;
$('#build-console').prev('h2').html('Build #' + buildId + ' console');
$('#build-console').html('');
@ -41,10 +41,14 @@ define([
});
});
builds.subscribe(function(build, action) {
buildsHash[build.id] = build;
$('#builds').html(buildsTemplate({
builds: _(buildsHash).values().reverse()
}));
buildsResource.subscribe(function(build, action) {
var oldBuild = _(builds).findWhere({id: build.id});
if (oldBuild) {
_(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() {
var number = 1;
var conditionsHash = {
1: {queue: {length: 0}, build: {status: 'waiting'}},
1: {queue: {length: 0}, build: {status: 'queued'}},
2: {queue: {length: 1}, build: {status: 'in-progress'}},
3: {queue: {length: 0}, build: {status: 'done'}},
4: 'Should never happend'
@ -92,7 +92,7 @@ describe('Distributor', function() {
it('instance should be created without errors', function() {
var number = 1;
var conditionsHash = {
1: {queue: {length: 0}, build: {status: 'waiting'}},
1: {queue: {length: 0}, build: {status: 'queued'}},
2: {queue: {length: 1}, build: {status: 'in-progress'}},
3: {
queue: {length: 0},