@atomist/sdm-pack-aspect
Version:
an Atomist SDM Extension Pack for visualizing drift across an organization
71 lines • 3.77 kB
JavaScript
;
/*
* Copyright © 2019 Atomist, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const automation_client_1 = require("@atomist/automation-client");
const _ = require("lodash");
const analysisTrackingPage_1 = require("../../../views/analysisTrackingPage");
const aspectTrackingPage_1 = require("../../../views/aspectTrackingPage");
const topLevelPage_1 = require("../../../views/topLevelPage");
function exposeAnalysisTrackingPage(conf) {
conf.express.get("/analysis", ...conf.handlers, (req, res, next) => __awaiter(this, void 0, void 0, function* () {
try {
const data = conf.analysisTracking.report();
res.send(topLevelPage_1.renderStaticReactNode(analysisTrackingPage_1.AnalysisTrackingPage(data), `Analyzing projects`, conf.instanceMetadata));
}
catch (e) {
automation_client_1.logger.error(e.stack);
next(e);
}
}));
conf.express.get("/analysis/aspects", ...conf.handlers, (req, res, next) => __awaiter(this, void 0, void 0, function* () {
try {
const data = conf.analysisTracking.report();
const allAspectTimings = _.flatten(data.analyses
.map(a => _.flatten(a.repos
.filter(r => r.progress === "Stopped")
.map(r => r.aspects))));
const timingsByAspect = _.groupBy(allAspectTimings, a => a.aspectName);
const summarized = Object.values(timingsByAspect).map(timings => {
return {
aspectName: timings[0].aspectName,
runs: timings.length,
totalFingerprints: timings.map(t => t.fingerprintsFound).reduce((a, b) => a + b, 0),
failures: timings.filter(f => !!f.error).length,
minMillis: Math.min(...timings.map(t => t.millisTaken)),
maxMillis: Math.max(...timings.map(t => t.millisTaken)),
totalTimeTaken: timings.map(t => t.millisTaken).reduce((a, b) => a + b, 0),
};
});
res.send(topLevelPage_1.renderStaticReactNode(aspectTrackingPage_1.AspectTrackingPage({ aspectPerformances: summarized }), `Performance of Aspects during Analysis`, conf.instanceMetadata));
}
catch (e) {
automation_client_1.logger.error(e.stack);
next(e);
}
}));
}
exports.exposeAnalysisTrackingPage = exposeAnalysisTrackingPage;
//# sourceMappingURL=analysisTrackingRoutes.js.map