UNPKG

morning-builds-core

Version:

Core functionality for Morning Builds

42 lines 2.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var dateFormat = require("date-fns/format"); var _ = require("lodash"); var Execution = /** @class */ (function () { function Execution(firebaseCrud) { this.firebaseCrud = firebaseCrud; } Execution.prototype.addExecution = function (buildState, date) { return this.firebaseCrud.create("execution/" + dateFormat(date, 'YYYY-MM-DD') + "/" + buildState.build.planKey + "-" + buildState.build.resultNumber, buildState); }; Execution.prototype.markAsReran = function (buildState, date) { return this.firebaseCrud.update("execution/" + dateFormat(date, 'YYYY-MM-DD') + "/" + buildState.planKey + "-" + buildState.resultNumber, { reran: true }); }; Execution.prototype.fetchExecution = function (date) { return this.firebaseCrud .read("execution/" + dateFormat(date, 'YYYY-MM-DD') + "/") .then(function (obj) { return Object.keys(obj || {}).map(function (k) { return (Object.assign({}, obj[k], { planKey: k })); }); }); }; Execution.prototype.fetchFailingBuild = function (date, planKey, resultNumber) { return this.firebaseCrud .read("execution/" + dateFormat(date, 'YYYY-MM-DD') + "/" + planKey + "-" + resultNumber) .then(function (buildState) { return buildState || {}; }); }; Execution.prototype.fetchExecutions = function (_a) { var _b = (_a === void 0 ? {} : _a).limit, limit = _b === void 0 ? 30 : _b; return this.firebaseCrud .read("execution", { limit: limit, topOrBottom: 'bottom' }) .then(function (node) { return Object.entries(node).map(function (_a) { var date = _a[0], builds = _a[1]; return ({ date: date, builds: builds }); }); }) .then(function (data) { return data.map(function (d) { d.builds = Object.values(d.builds); return d; }); }) .then(function (data) { return _.orderBy(data, ['date'], ['desc']); }); }; return Execution; }()); exports.Execution = Execution; //# sourceMappingURL=execution.js.map