From cab3d09ade0e9fac32d1de355c93080793bb1386 Mon Sep 17 00:00:00 2001 From: Martin Fosco Date: Mon, 15 Mar 2021 11:14:00 -0300 Subject: [PATCH] Block UI based on pipeline state (#62) * Add pipeline status to pipeline updates to avoid having to call GET pipeline on the ui every time we need to know its status * Fix tests * WIP * Remove console log Co-authored-by: Martin Fosco --- src/api/route-services/pipeline-response.js | 4 ++++ tests/api/route-services/pipeline-response.test.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/api/route-services/pipeline-response.js b/src/api/route-services/pipeline-response.js index 19a77f8db..169f4ee09 100644 --- a/src/api/route-services/pipeline-response.js +++ b/src/api/route-services/pipeline-response.js @@ -4,6 +4,7 @@ const logger = require('../../utils/logging'); const ExperimentService = require('./experiment'); const PlotsTablesService = require('./plots-tables'); +const pipelineStatus = require('../general-services/pipeline-status'); const experimentService = new ExperimentService(); const plotsTableService = new PlotsTablesService(); @@ -85,10 +86,13 @@ const pipelineResponse = async (io, message) => { experimentService.updateProcessingConfig(experimentId, [{ name: taskName, body: output.config }]); + const statusRes = await pipelineStatus(experimentId); + // Concatenate into a proper response. const response = { ...message, output, + status: statusRes, }; logger.log('Sending to all clients subscribed to experiment', experimentId); diff --git a/tests/api/route-services/pipeline-response.test.js b/tests/api/route-services/pipeline-response.test.js index 4a9c4657f..584c2c28f 100644 --- a/tests/api/route-services/pipeline-response.test.js +++ b/tests/api/route-services/pipeline-response.test.js @@ -6,6 +6,10 @@ const ioServer = require('socket.io')({ const AWS = require('../../../src/utils/requireAWS'); const pipelineResponse = require('../../../src/api/route-services/pipeline-response'); +jest.mock('../../../src/api/general-services/pipeline-status', () => jest.fn().mockImplementation(() => ({ + pipelineStatus: () => ({}), +}))); + describe('Test Pipeline Response Service', () => { let io; let client;