diff --git a/1/ecolyo.1a5ceac1d989c9e1527a.js b/1/ecolyo.cc1756f7d8588919bece.js similarity index 99% rename from 1/ecolyo.1a5ceac1d989c9e1527a.js rename to 1/ecolyo.cc1756f7d8588919bece.js index caaf7f54a49c776f3d4fe8345d103cd4cf17c397..9e6a1b07c164de5199b3d0a61eb45269c934c342 100644 --- a/1/ecolyo.1a5ceac1d989c9e1527a.js +++ b/1/ecolyo.cc1756f7d8588919bece.js @@ -1918,9 +1918,7 @@ var useKonnectorAuth = function useKonnectorAuth(fluidType, login, password) { _logger.default.error(_context2.t1); - Sentry.captureException(JSON.stringify({ - error: _context2.t1 - })); + Sentry.captureException(_context2.t1); case 31: case "end": @@ -3802,6 +3800,8 @@ var _react2 = _interopRequireWildcard(__webpack_require__("q1tI")); var _hooks = __webpack_require__("Zlw4"); +var _logger = _interopRequireDefault(__webpack_require__("gjtA")); + var _picto = __webpack_require__("6DBe"); __webpack_require__("GGWR"); @@ -3916,18 +3916,19 @@ var FormLogin = function FormLogin() { return update(); case 16: - _context.next = 22; + _context.next = 23; break; case 18: _context.prev = 18; _context.t0 = _context["catch"](1); - Sentry.captureException(JSON.stringify({ - error: _context.t0 - })); + + _logger.default.error(_context.t0); + + Sentry.captureException(_context.t0); setLoading(false); - case 22: + case 23: case "end": return _context.stop(); } diff --git a/7/ecolyo.4bbd5d9fa41ab85d937f.js b/7/ecolyo.12a39cd37a38e43e4383.js similarity index 68% rename from 7/ecolyo.4bbd5d9fa41ab85d937f.js rename to 7/ecolyo.12a39cd37a38e43e4383.js index a59be326530bdbcf4d9f7ca9ef206dd9f47614eb..23a5f08b917eeef7f6e55ffee6c631b7f1077f87 100644 --- a/7/ecolyo.4bbd5d9fa41ab85d937f.js +++ b/7/ecolyo.12a39cd37a38e43e4383.js @@ -131,13 +131,13 @@ var BarChart = function BarChart(_ref) { marginTop: marginTop }), /*#__PURE__*/_react.default.createElement("g", { transform: "translate(".concat(marginLeft, ",").concat(marginTop, ")") - }, chartData.actualData.map(function (d, index) { + }, chartData.actualData.map(function (data, index) { var _chartData$comparison; return /*#__PURE__*/_react.default.createElement(_Bar.default, { key: index, index: index, - dataload: d, + dataload: data, compareDataload: (_chartData$comparison = chartData.comparisonData) !== null && _chartData$comparison !== void 0 && _chartData$comparison[index] ? chartData.comparisonData[index] : null, fluidType: fluidType, timeStep: timeStep, @@ -146,7 +146,7 @@ var BarChart = function BarChart(_ref) { yScale: yScale, height: getContentHeight(), isSwitching: isSwitching, - isMultiMissingFluid: d.state === _enums.DataloadState.AGGREGATED_WITH_EMPTY || d.state === _enums.DataloadState.AGGREGATED_WITH_COMING || d.state === _enums.DataloadState.AGGREGATED_WITH_HOLE_OR_MISSING ? true : false, + isMultiMissingFluid: data.state === _enums.DataloadState.AGGREGATED_WITH_EMPTY || data.state === _enums.DataloadState.AGGREGATED_WITH_COMING || data.state === _enums.DataloadState.AGGREGATED_WITH_HOLE_OR_MISSING, clickable: clickable, average: averageConsumption }); @@ -471,6 +471,472 @@ exports.push([module.i, "/** BLACK **/\n/** RED **/\n/** YELLOW **/\n/** ORANGE +/***/ }), + +/***/ "VjcQ": +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _interopRequireDefault = __webpack_require__("TqRt"); + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _regenerator = _interopRequireDefault(__webpack_require__("o0o1")); + +var _slicedToArray2 = _interopRequireDefault(__webpack_require__("J4zp")); + +var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__("yXPU")); + +var _classCallCheck2 = _interopRequireDefault(__webpack_require__("lwsE")); + +var _createClass2 = _interopRequireDefault(__webpack_require__("W8MJ")); + +var _defineProperty2 = _interopRequireDefault(__webpack_require__("lSNA")); + +var Sentry = _interopRequireWildcard(__webpack_require__("agHs")); + +var _cozyClient = __webpack_require__("SH7X"); + +var _cozyLogger = _interopRequireDefault(__webpack_require__("Vggm")); + +var _doctypes = __webpack_require__("D2hQ"); + +var _logger = _interopRequireDefault(__webpack_require__("gjtA")); + +var _fluidConfig = _interopRequireDefault(__webpack_require__("JIzA")); + +function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } + +function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } + +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +var logStack = _cozyLogger.default.namespace('fluidPricesService'); + +var FluidPricesService = /*#__PURE__*/function () { + function FluidPricesService(_client) { + (0, _classCallCheck2.default)(this, FluidPricesService); + (0, _defineProperty2.default)(this, "_client", void 0); + this._client = _client; + } + /** + * Get all prices available in database + * @returns {FluidPrice[]} + */ + + + (0, _createClass2.default)(FluidPricesService, [{ + key: "getAllPrices", + value: function () { + var _getAllPrices = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() { + var query, _yield$this$_client$q, fluidsPrices; + + return _regenerator.default.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + query = (0, _cozyClient.Q)(_doctypes.FLUIDSPRICES_DOCTYPE).limitBy(900); // TODO : handle case of 1000+ entries in doctype + + _context.next = 3; + return this._client.query(query); + + case 3: + _yield$this$_client$q = _context.sent; + fluidsPrices = _yield$this$_client$q.data; + return _context.abrupt("return", fluidsPrices); + + case 6: + case "end": + return _context.stop(); + } + } + }, _callee, this); + })); + + function getAllPrices() { + return _getAllPrices.apply(this, arguments); + } + + return getAllPrices; + }() + /** + * Get a price according to a fluidType and a data. This method return the nearest and valid price for the given date. + * @param {FluidType} fluidType + * @param {DateTime} date + * @returns {FluidPrice} + */ + + }, { + key: "getPrices", + value: function () { + var _getPrices = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(fluidType, date) { + var query, _yield$this$_client$q2, fluidsPrices; + + return _regenerator.default.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + query = (0, _cozyClient.Q)(_doctypes.FLUIDSPRICES_DOCTYPE).where({ + startDate: { + $lte: date.toISO({ + suppressMilliseconds: true + }).toString() + }, + fluidType: fluidType + }).indexFields(['startDate']).sortBy([{ + startDate: 'desc' + }]).limitBy(1); + _context2.next = 3; + return this._client.query(query); + + case 3: + _yield$this$_client$q2 = _context2.sent; + fluidsPrices = _yield$this$_client$q2.data; + return _context2.abrupt("return", fluidsPrices[0]); + + case 6: + case "end": + return _context2.stop(); + } + } + }, _callee2, this); + })); + + function getPrices(_x, _x2) { + return _getPrices.apply(this, arguments); + } + + return getPrices; + }() + /** + * Get current prices for all fluidTypes. + * @returns {FluidPrice[]} + */ + + }, { + key: "getAllLastPrices", + value: function () { + var _getAllLastPrices = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() { + var query, _yield$this$_client$q3, fluidsPrices, configService, fluidConfig, recoveredFluidsPrices; + + return _regenerator.default.wrap(function _callee3$(_context3) { + while (1) { + switch (_context3.prev = _context3.next) { + case 0: + query = (0, _cozyClient.Q)(_doctypes.FLUIDSPRICES_DOCTYPE).where({ + endDate: { + $eq: '' + } + }).indexFields(['fluidType']).sortBy([{ + fluidType: 'asc' + }]).limitBy(3); + _context3.next = 3; + return this._client.query(query); + + case 3: + _yield$this$_client$q3 = _context3.sent; + fluidsPrices = _yield$this$_client$q3.data; + + if (!(fluidsPrices.length !== 3)) { + _context3.next = 12; + break; + } + + configService = new _fluidConfig.default(); + fluidConfig = configService.getFluidConfig(); + recoveredFluidsPrices = []; // Getting default fluid price + + fluidConfig.forEach(function (config) { + recoveredFluidsPrices.push({ + _id: '0', + fluidType: config.fluidTypeId, + price: config.coefficient, + startDate: config.startDate, + endDate: '' + }); + }); // Replacing default prices if available + + fluidsPrices.forEach(function (fluidPrice) { + recoveredFluidsPrices[fluidPrice.fluidType] = fluidPrice; + }); + return _context3.abrupt("return", recoveredFluidsPrices); + + case 12: + return _context3.abrupt("return", fluidsPrices); + + case 13: + case "end": + return _context3.stop(); + } + } + }, _callee3, this); + })); + + function getAllLastPrices() { + return _getAllLastPrices.apply(this, arguments); + } + + return getAllLastPrices; + }() + /** + * Delete all fluidPrices entities from the db + * @returns {boolean} - true when deleted with success + * @throws {Error} + */ + + }, { + key: "deleteAllFluidsPrices", + value: function () { + var _deleteAllFluidsPrices = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() { + var fluidsPrices, _iterator, _step, price, errorMessage; + + return _regenerator.default.wrap(function _callee4$(_context4) { + while (1) { + switch (_context4.prev = _context4.next) { + case 0: + _context4.next = 2; + return this.getAllPrices(); + + case 2: + fluidsPrices = _context4.sent; + _context4.prev = 3; + _iterator = _createForOfIteratorHelper(fluidsPrices); + _context4.prev = 5; + + _iterator.s(); + + case 7: + if ((_step = _iterator.n()).done) { + _context4.next = 13; + break; + } + + price = _step.value; + _context4.next = 11; + return this._client.destroy(price); + + case 11: + _context4.next = 7; + break; + + case 13: + _context4.next = 18; + break; + + case 15: + _context4.prev = 15; + _context4.t0 = _context4["catch"](5); + + _iterator.e(_context4.t0); + + case 18: + _context4.prev = 18; + + _iterator.f(); + + return _context4.finish(18); + + case 21: + return _context4.abrupt("return", true); + + case 24: + _context4.prev = 24; + _context4.t1 = _context4["catch"](3); + errorMessage = "deleteAllFluidsPrices: ".concat(JSON.stringify(_context4.t1)); + logStack('error', errorMessage); + + _logger.default.error(errorMessage); + + Sentry.captureException(_context4.t1); + return _context4.abrupt("return", false); + + case 31: + case "end": + return _context4.stop(); + } + } + }, _callee4, this, [[3, 24], [5, 15, 18, 21]]); + })); + + function deleteAllFluidsPrices() { + return _deleteAllFluidsPrices.apply(this, arguments); + } + + return deleteAllFluidsPrices; + }() + /** + * Check if a fluidprice exists in db + * @param {FluidPrice} fluidPrice + * @returns {FluidPrice | null} price or null + */ + + }, { + key: "checkIfPriceExists", + value: function () { + var _checkIfPriceExists = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(fluidPrice) { + var query, _yield$this$_client$q4, _yield$this$_client$q5, price; + + return _regenerator.default.wrap(function _callee5$(_context5) { + while (1) { + switch (_context5.prev = _context5.next) { + case 0: + query = (0, _cozyClient.Q)(_doctypes.FLUIDSPRICES_DOCTYPE).where({ + startDate: { + $eq: fluidPrice.startDate + }, + fluidType: { + $eq: fluidPrice.fluidType + } + }); + _context5.next = 3; + return this._client.query(query); + + case 3: + _yield$this$_client$q4 = _context5.sent; + _yield$this$_client$q5 = (0, _slicedToArray2.default)(_yield$this$_client$q4.data, 1); + price = _yield$this$_client$q5[0]; + + if (!price) { + _context5.next = 10; + break; + } + + return _context5.abrupt("return", price); + + case 10: + return _context5.abrupt("return", null); + + case 11: + case "end": + return _context5.stop(); + } + } + }, _callee5, this); + })); + + function checkIfPriceExists(_x3) { + return _checkIfPriceExists.apply(this, arguments); + } + + return checkIfPriceExists; + }() + /** + * Creates a new fluidPrice + * @param {FluidPrice} fluidPrice + * @returns {FluidPrice | null} price or null + */ + + }, { + key: "createPrice", + value: function () { + var _createPrice = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(newPrice) { + var _yield$this$_client$c, createdPrice, errorMessage; + + return _regenerator.default.wrap(function _callee6$(_context6) { + while (1) { + switch (_context6.prev = _context6.next) { + case 0: + _context6.prev = 0; + _context6.next = 3; + return this._client.create(_doctypes.FLUIDSPRICES_DOCTYPE, newPrice); + + case 3: + _yield$this$_client$c = _context6.sent; + createdPrice = _yield$this$_client$c.data; + return _context6.abrupt("return", createdPrice); + + case 8: + _context6.prev = 8; + _context6.t0 = _context6["catch"](0); + errorMessage = "'Error creating new createdPrice: ".concat(JSON.stringify(_context6.t0)); + logStack('error', errorMessage); + + _logger.default.error(errorMessage); + + Sentry.captureException(_context6.t0); + throw _context6.t0; + + case 15: + case "end": + return _context6.stop(); + } + } + }, _callee6, this, [[0, 8]]); + })); + + function createPrice(_x4) { + return _createPrice.apply(this, arguments); + } + + return createPrice; + }() + /** + * Updates a price in db + * @param {FluidPrice} doc + * @param {Partial<FluidPrice>} attributes + * @returns {FluidPrice | null} + */ + + }, { + key: "updatePrice", + value: function () { + var _updatePrice = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(doc, attributes) { + var _yield$this$_client$s, fluidPrice; + + return _regenerator.default.wrap(function _callee7$(_context7) { + while (1) { + switch (_context7.prev = _context7.next) { + case 0: + _context7.next = 2; + return this._client.save(_objectSpread(_objectSpread({}, doc), attributes)); + + case 2: + _yield$this$_client$s = _context7.sent; + fluidPrice = _yield$this$_client$s.data; + + if (!fluidPrice) { + _context7.next = 6; + break; + } + + return _context7.abrupt("return", fluidPrice); + + case 6: + return _context7.abrupt("return", null); + + case 7: + case "end": + return _context7.stop(); + } + } + }, _callee7, this); + })); + + function updatePrice(_x5, _x6) { + return _updatePrice.apply(this, arguments); + } + + return updatePrice; + }() + }]); + return FluidPricesService; +}(); + +exports.default = FluidPricesService; + /***/ }), /***/ "ZpZG": diff --git a/9/ecolyo.30da7dc1931663d9bbdf.js b/9/ecolyo.3e835fcd8f4cc16308af.js similarity index 99% rename from 9/ecolyo.30da7dc1931663d9bbdf.js rename to 9/ecolyo.3e835fcd8f4cc16308af.js index 6e05ee02728bead36980883644ef5d9bec6afb7e..28a8b31962f9184256a5090e152bd8c352ac7957 100644 --- a/9/ecolyo.30da7dc1931663d9bbdf.js +++ b/9/ecolyo.3e835fcd8f4cc16308af.js @@ -253,7 +253,7 @@ var EnedisMonthlyAnalysisDataService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context4.t0); throw _context4.t0; case 15: diff --git a/app/ecolyo.6cfa06565ced67bf5184.js b/app/ecolyo.284c5548bdf91c564a24.js similarity index 99% rename from app/ecolyo.6cfa06565ced67bf5184.js rename to app/ecolyo.284c5548bdf91c564a24.js index 96c693d503e76c05d7b7440aa5993c71ef3fd419..3573f545cdc9a4d5425f1db8d033eed4dcb0eb5d 100644 --- a/app/ecolyo.6cfa06565ced67bf5184.js +++ b/app/ecolyo.284c5548bdf91c564a24.js @@ -64,7 +64,7 @@ /******/ /******/ // script path function /******/ function jsonpScriptSrc(chunkId) { -/******/ return __webpack_require__.p + "" + ({}[chunkId]||chunkId) + "/ecolyo." + {"1":"1a5ceac1d989c9e1527a","2":"62e5292a592368584bc8","4":"ed87413fc9f81039a5c7","5":"eb4d57e9d898eeff1c9e","6":"19b72783897b01dc97e2","7":"4bbd5d9fa41ab85d937f","8":"cd70845caf52d7dce840","9":"30da7dc1931663d9bbdf","10":"2946952809565809b75b"}[chunkId] + ".js" +/******/ return __webpack_require__.p + "" + ({}[chunkId]||chunkId) + "/ecolyo." + {"1":"cc1756f7d8588919bece","2":"62e5292a592368584bc8","4":"ed87413fc9f81039a5c7","5":"eb4d57e9d898eeff1c9e","6":"19b72783897b01dc97e2","7":"12a39cd37a38e43e4383","8":"cd70845caf52d7dce840","9":"3e835fcd8f4cc16308af","10":"2946952809565809b75b"}[chunkId] + ".js" /******/ } /******/ /******/ // The require function @@ -1846,9 +1846,7 @@ var SplashRoot = function SplashRoot(_ref) { _logger.default.error("[Initialization] Error : ".concat(_context7.t0)); - Sentry.captureException(JSON.stringify({ - error: _context7.t0 - })); + Sentry.captureException(_context7.t0); case 91: _context7.prev = 91; @@ -3813,7 +3811,7 @@ var MailService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context.t0); throw new Error(errorMessage); case 12: @@ -4573,7 +4571,7 @@ var PartnersInfoService = /*#__PURE__*/function () { /** * Get information from backoffice about the status of partners' service * On success, respond the partnersInfo - * Else, throw an error + * Else, return undefined */ @@ -4607,7 +4605,7 @@ var PartnersInfoService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context.t0); case 16: case "end": @@ -7094,7 +7092,7 @@ var TriggerService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context5.t0); throw new Error('Delete trigger failed'); case 13: @@ -7263,7 +7261,7 @@ var ProfileTypeService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context.t0); return _context.abrupt("return", _heating.default.dju_average_by_month[month - 1]); case 22: @@ -19163,472 +19161,6 @@ exports.TimeStep = TimeStep; /***/ }), -/***/ "VjcQ": -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var _interopRequireDefault = __webpack_require__("TqRt"); - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; - -var _regenerator = _interopRequireDefault(__webpack_require__("o0o1")); - -var _slicedToArray2 = _interopRequireDefault(__webpack_require__("J4zp")); - -var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__("yXPU")); - -var _classCallCheck2 = _interopRequireDefault(__webpack_require__("lwsE")); - -var _createClass2 = _interopRequireDefault(__webpack_require__("W8MJ")); - -var _defineProperty2 = _interopRequireDefault(__webpack_require__("lSNA")); - -var Sentry = _interopRequireWildcard(__webpack_require__("agHs")); - -var _cozyClient = __webpack_require__("SH7X"); - -var _cozyLogger = _interopRequireDefault(__webpack_require__("Vggm")); - -var _doctypes = __webpack_require__("D2hQ"); - -var _logger = _interopRequireDefault(__webpack_require__("gjtA")); - -var _fluidConfig = _interopRequireDefault(__webpack_require__("JIzA")); - -function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } - -function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } - -function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } - -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } - -function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } - -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } - -function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } - -var logStack = _cozyLogger.default.namespace('fluidPricesService'); - -var FluidPricesService = /*#__PURE__*/function () { - function FluidPricesService(_client) { - (0, _classCallCheck2.default)(this, FluidPricesService); - (0, _defineProperty2.default)(this, "_client", void 0); - this._client = _client; - } - /** - * Get all prices available in database - * @returns {FluidPrice[]} - */ - - - (0, _createClass2.default)(FluidPricesService, [{ - key: "getAllPrices", - value: function () { - var _getAllPrices = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() { - var query, _yield$this$_client$q, fluidsPrices; - - return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - query = (0, _cozyClient.Q)(_doctypes.FLUIDSPRICES_DOCTYPE).limitBy(900); // TODO : handle case of 1000+ entries in doctype - - _context.next = 3; - return this._client.query(query); - - case 3: - _yield$this$_client$q = _context.sent; - fluidsPrices = _yield$this$_client$q.data; - return _context.abrupt("return", fluidsPrices); - - case 6: - case "end": - return _context.stop(); - } - } - }, _callee, this); - })); - - function getAllPrices() { - return _getAllPrices.apply(this, arguments); - } - - return getAllPrices; - }() - /** - * Get a price according to a fluidType and a data. This method return the nearest and valid price for the given date. - * @param {FluidType} fluidType - * @param {DateTime} date - * @returns {FluidPrice} - */ - - }, { - key: "getPrices", - value: function () { - var _getPrices = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(fluidType, date) { - var query, _yield$this$_client$q2, fluidsPrices; - - return _regenerator.default.wrap(function _callee2$(_context2) { - while (1) { - switch (_context2.prev = _context2.next) { - case 0: - query = (0, _cozyClient.Q)(_doctypes.FLUIDSPRICES_DOCTYPE).where({ - startDate: { - $lte: date.toISO({ - suppressMilliseconds: true - }).toString() - }, - fluidType: fluidType - }).indexFields(['startDate']).sortBy([{ - startDate: 'desc' - }]).limitBy(1); - _context2.next = 3; - return this._client.query(query); - - case 3: - _yield$this$_client$q2 = _context2.sent; - fluidsPrices = _yield$this$_client$q2.data; - return _context2.abrupt("return", fluidsPrices[0]); - - case 6: - case "end": - return _context2.stop(); - } - } - }, _callee2, this); - })); - - function getPrices(_x, _x2) { - return _getPrices.apply(this, arguments); - } - - return getPrices; - }() - /** - * Get current prices for all fluidTypes. - * @returns {FluidPrice[]} - */ - - }, { - key: "getAllLastPrices", - value: function () { - var _getAllLastPrices = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() { - var query, _yield$this$_client$q3, fluidsPrices, configService, fluidConfig, recoveredFluidsPrices; - - return _regenerator.default.wrap(function _callee3$(_context3) { - while (1) { - switch (_context3.prev = _context3.next) { - case 0: - query = (0, _cozyClient.Q)(_doctypes.FLUIDSPRICES_DOCTYPE).where({ - endDate: { - $eq: '' - } - }).indexFields(['fluidType']).sortBy([{ - fluidType: 'asc' - }]).limitBy(3); - _context3.next = 3; - return this._client.query(query); - - case 3: - _yield$this$_client$q3 = _context3.sent; - fluidsPrices = _yield$this$_client$q3.data; - - if (!(fluidsPrices.length !== 3)) { - _context3.next = 12; - break; - } - - configService = new _fluidConfig.default(); - fluidConfig = configService.getFluidConfig(); - recoveredFluidsPrices = []; // Getting default fluid price - - fluidConfig.forEach(function (config) { - recoveredFluidsPrices.push({ - _id: '0', - fluidType: config.fluidTypeId, - price: config.coefficient, - startDate: config.startDate, - endDate: '' - }); - }); // Replacing default prices if available - - fluidsPrices.forEach(function (fluidPrice) { - recoveredFluidsPrices[fluidPrice.fluidType] = fluidPrice; - }); - return _context3.abrupt("return", recoveredFluidsPrices); - - case 12: - return _context3.abrupt("return", fluidsPrices); - - case 13: - case "end": - return _context3.stop(); - } - } - }, _callee3, this); - })); - - function getAllLastPrices() { - return _getAllLastPrices.apply(this, arguments); - } - - return getAllLastPrices; - }() - /** - * Delete all fluidPrices entities from the db - * @returns {boolean} - true when deleted with success - * @throws {Error} - */ - - }, { - key: "deleteAllFluidsPrices", - value: function () { - var _deleteAllFluidsPrices = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() { - var fluidsPrices, _iterator, _step, price, errorMessage; - - return _regenerator.default.wrap(function _callee4$(_context4) { - while (1) { - switch (_context4.prev = _context4.next) { - case 0: - _context4.next = 2; - return this.getAllPrices(); - - case 2: - fluidsPrices = _context4.sent; - _context4.prev = 3; - _iterator = _createForOfIteratorHelper(fluidsPrices); - _context4.prev = 5; - - _iterator.s(); - - case 7: - if ((_step = _iterator.n()).done) { - _context4.next = 13; - break; - } - - price = _step.value; - _context4.next = 11; - return this._client.destroy(price); - - case 11: - _context4.next = 7; - break; - - case 13: - _context4.next = 18; - break; - - case 15: - _context4.prev = 15; - _context4.t0 = _context4["catch"](5); - - _iterator.e(_context4.t0); - - case 18: - _context4.prev = 18; - - _iterator.f(); - - return _context4.finish(18); - - case 21: - return _context4.abrupt("return", true); - - case 24: - _context4.prev = 24; - _context4.t1 = _context4["catch"](3); - errorMessage = "deleteAllFluidsPrices: ".concat(JSON.stringify(_context4.t1)); - logStack('error', errorMessage); - - _logger.default.error(errorMessage); - - Sentry.captureException(errorMessage); - return _context4.abrupt("return", false); - - case 31: - case "end": - return _context4.stop(); - } - } - }, _callee4, this, [[3, 24], [5, 15, 18, 21]]); - })); - - function deleteAllFluidsPrices() { - return _deleteAllFluidsPrices.apply(this, arguments); - } - - return deleteAllFluidsPrices; - }() - /** - * Check if a fluidprice exists in db - * @param {FluidPrice} fluidPrice - * @returns {FluidPrice | null} price or null - */ - - }, { - key: "checkIfPriceExists", - value: function () { - var _checkIfPriceExists = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(fluidPrice) { - var query, _yield$this$_client$q4, _yield$this$_client$q5, price; - - return _regenerator.default.wrap(function _callee5$(_context5) { - while (1) { - switch (_context5.prev = _context5.next) { - case 0: - query = (0, _cozyClient.Q)(_doctypes.FLUIDSPRICES_DOCTYPE).where({ - startDate: { - $eq: fluidPrice.startDate - }, - fluidType: { - $eq: fluidPrice.fluidType - } - }); - _context5.next = 3; - return this._client.query(query); - - case 3: - _yield$this$_client$q4 = _context5.sent; - _yield$this$_client$q5 = (0, _slicedToArray2.default)(_yield$this$_client$q4.data, 1); - price = _yield$this$_client$q5[0]; - - if (!price) { - _context5.next = 10; - break; - } - - return _context5.abrupt("return", price); - - case 10: - return _context5.abrupt("return", null); - - case 11: - case "end": - return _context5.stop(); - } - } - }, _callee5, this); - })); - - function checkIfPriceExists(_x3) { - return _checkIfPriceExists.apply(this, arguments); - } - - return checkIfPriceExists; - }() - /** - * Creates a new fluidPrice - * @param {FluidPrice} fluidPrice - * @returns {FluidPrice | null} price or null - */ - - }, { - key: "createPrice", - value: function () { - var _createPrice = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(newPrice) { - var _yield$this$_client$c, createdPrice, errorMessage; - - return _regenerator.default.wrap(function _callee6$(_context6) { - while (1) { - switch (_context6.prev = _context6.next) { - case 0: - _context6.prev = 0; - _context6.next = 3; - return this._client.create(_doctypes.FLUIDSPRICES_DOCTYPE, newPrice); - - case 3: - _yield$this$_client$c = _context6.sent; - createdPrice = _yield$this$_client$c.data; - return _context6.abrupt("return", createdPrice); - - case 8: - _context6.prev = 8; - _context6.t0 = _context6["catch"](0); - errorMessage = "'Error creating new createdPrice: ".concat(JSON.stringify(_context6.t0)); - logStack('error', errorMessage); - - _logger.default.error(errorMessage); - - Sentry.captureException(errorMessage); - throw _context6.t0; - - case 15: - case "end": - return _context6.stop(); - } - } - }, _callee6, this, [[0, 8]]); - })); - - function createPrice(_x4) { - return _createPrice.apply(this, arguments); - } - - return createPrice; - }() - /** - * Updates a price in db - * @param {FluidPrice} doc - * @param {Partial<FluidPrice>} attributes - * @returns {FluidPrice | null} - */ - - }, { - key: "updatePrice", - value: function () { - var _updatePrice = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(doc, attributes) { - var _yield$this$_client$s, fluidPrice; - - return _regenerator.default.wrap(function _callee7$(_context7) { - while (1) { - switch (_context7.prev = _context7.next) { - case 0: - _context7.next = 2; - return this._client.save(_objectSpread(_objectSpread({}, doc), attributes)); - - case 2: - _yield$this$_client$s = _context7.sent; - fluidPrice = _yield$this$_client$s.data; - - if (!fluidPrice) { - _context7.next = 6; - break; - } - - return _context7.abrupt("return", fluidPrice); - - case 6: - return _context7.abrupt("return", null); - - case 7: - case "end": - return _context7.stop(); - } - } - }, _callee7, this); - })); - - function updatePrice(_x5, _x6) { - return _updatePrice.apply(this, arguments); - } - - return updatePrice; - }() - }]); - return FluidPricesService; -}(); - -exports.default = FluidPricesService; - -/***/ }), - /***/ "Vpb/": /***/ (function(module, exports, __webpack_require__) { @@ -19989,7 +19521,7 @@ var DuelService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context5.t1); throw _context5.t1; case 33: @@ -20518,7 +20050,7 @@ var CustomPopupService = /*#__PURE__*/function () { /** * Get information from backoffice about the status of custom popup * On success, respond the customPopup - * Else, throw an error + * Else, return undefined */ @@ -20552,7 +20084,7 @@ var CustomPopupService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context.t0); case 16: case "end": @@ -22897,7 +22429,7 @@ var ProfileTypeEntityService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context4.t1); return _context4.abrupt("return", false); case 28: @@ -24313,7 +23845,7 @@ var UsageEventService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context3.t0); case 22: case "end": @@ -24346,68 +23878,65 @@ var UsageEventService = /*#__PURE__*/function () { while (1) { switch (_context4.prev = _context4.next) { case 0: + _context4.prev = 0; _iterator = _createForOfIteratorHelper(events); - _context4.prev = 1; + _context4.prev = 2; _iterator.s(); - case 3: + case 4: if ((_step = _iterator.n()).done) { - _context4.next = 18; + _context4.next = 10; break; } event = _step.value; - _context4.prev = 5; _context4.next = 8; return client.save(_objectSpread(_objectSpread({}, event), {}, { aggregated: true })); case 8: - _context4.next = 16; + _context4.next = 4; break; case 10: - _context4.prev = 10; - _context4.t0 = _context4["catch"](5); - errorMessage = "UsageEvent service error on updateUsageEventsAggregated: ".concat(JSON.stringify(_context4.t0)); - logStack('error', errorMessage); - - _logger.default.error(errorMessage); - - Sentry.captureException(errorMessage); - - case 16: - _context4.next = 3; - break; - - case 18: - _context4.next = 23; + _context4.next = 15; break; - case 20: - _context4.prev = 20; - _context4.t1 = _context4["catch"](1); + case 12: + _context4.prev = 12; + _context4.t0 = _context4["catch"](2); - _iterator.e(_context4.t1); + _iterator.e(_context4.t0); - case 23: - _context4.prev = 23; + case 15: + _context4.prev = 15; _iterator.f(); - return _context4.finish(23); + return _context4.finish(15); - case 26: + case 18: return _context4.abrupt("return", true); - case 27: + case 21: + _context4.prev = 21; + _context4.t1 = _context4["catch"](0); + errorMessage = "UsageEvent service error on updateUsageEventsAggregated: ".concat(JSON.stringify(_context4.t1)); + logStack('error', errorMessage); + + _logger.default.error(errorMessage); + + Sentry.captureException(_context4.t1); + throw new Error('Could not update all events'); + + case 28: case "end": return _context4.stop(); } } - }, _callee4, null, [[1, 20, 23, 26], [5, 10]]); + }, _callee4, null, [[0, 21], [2, 12, 15, 18]]); })); function updateUsageEventsAggregated(_x8, _x9) { @@ -25919,7 +25448,7 @@ var AccountService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context2.t0); throw new Error('Get account failed'); case 14: @@ -26017,7 +25546,7 @@ var AccountService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context3.t0); return _context3.abrupt("return", null); case 29: @@ -26065,7 +25594,7 @@ var AccountService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context4.t0); return _context4.abrupt("return", []); case 16: @@ -26107,7 +25636,7 @@ var AccountService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context5.t0); throw new Error('Update account failed'); case 14: @@ -26148,7 +25677,7 @@ var AccountService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context6.t0); throw new Error(errorMessage); case 13: @@ -28657,7 +28186,7 @@ var ChallengeService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context9.t1); throw _context9.t1; case 33: @@ -28764,7 +28293,7 @@ var ChallengeService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context11.t0); throw _context11.t0; case 20: @@ -28827,7 +28356,7 @@ var ChallengeService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context12.t0); throw _context12.t0; case 17: @@ -29097,7 +28626,7 @@ var ChallengeService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context13.t1); throw _context13.t1; case 107: @@ -30192,9 +29721,7 @@ function _migrate() { _context8.prev = 50; _context8.t3 = _context8["catch"](16); console.error(_context8.t3); - Sentry.captureException(JSON.stringify({ - error: _context8.t3 - })); + Sentry.captureException(_context8.t3); result = { type: _migration.MIGRATION_RESULT_FAILED, errors: [_context8.t3.toString()] @@ -32110,10 +31637,10 @@ var Bar = function Bar(_ref) { var index = _ref.index, dataload = _ref.dataload, + compare = _ref.compare, compareDataload = _ref.compareDataload, fluidType = _ref.fluidType, timeStep = _ref.timeStep, - compare = _ref.compare, xScale = _ref.xScale, yScale = _ref.yScale, height = _ref.height, @@ -32127,9 +31654,10 @@ var Bar = function Bar(_ref) { var dispatch = (0, _hooks.useAppDispatch)(); var _useAppSelector = (0, _hooks.useAppSelector)(function (state) { - return state.ecolyo.chart; + return state.ecolyo; }), - selectedDate = _useAppSelector.selectedDate; + selectedDate = _useAppSelector.chart.selectedDate, + fluidStatus = _useAppSelector.global.fluidStatus; var _useState = (0, _react.useState)(false), _useState2 = (0, _slicedToArray2.default)(_useState, 2), @@ -32213,6 +31741,9 @@ var Bar = function Bar(_ref) { return compare ? xScale.bandwidth() / 2 : xScale.bandwidth(); }; + var lastDataDate = fluidType !== _enums.FluidType.MULTIFLUID && fluidStatus[fluidType].lastDataDate; + var dataMissingUpcoming = Boolean(lastDataDate && dataload.date > lastDataDate && dataload.date < _luxon.DateTime.local()); + var topRoundedRect = function topRoundedRect(x, y, width, height) { var radius = height > 4 ? 4 : height / 4; return "\n M".concat(x, ",").concat(y + radius, "\n a").concat(radius, ",").concat(radius, " 0 0 1 ").concat(radius, ",").concat(-radius, "\n h").concat(width - 2 * radius, "\n a").concat(radius, ",").concat(radius, " 0 0 1 ").concat(radius, ",").concat(radius, "\n v").concat(height - radius, "\n h").concat(-width, "\n z"); @@ -32237,7 +31768,7 @@ var Bar = function Bar(_ref) { height: height + 40, className: "background-".concat(barBackgroundClass), fill: "#E0E0E0" - })), height > 0 && dataload.state === _enums.DataloadState.COMING && dataload.date < _luxon.DateTime.local() && /*#__PURE__*/_react.default.createElement("g", { + })), height > 0 && dataMissingUpcoming && /*#__PURE__*/_react.default.createElement("g", { transform: "translate(".concat(xScaleValue, ", ").concat(yScaleValue, ")"), className: "barFill" }, /*#__PURE__*/_react.default.createElement("defs", null, /*#__PURE__*/_react.default.createElement("linearGradient", { @@ -32318,7 +31849,10 @@ var Bar = function Bar(_ref) { return undefined; }, onAnimationEnd: onAnimationEnd - })) : height > 0 && dataload.value && dataload.value >= 0 && /*#__PURE__*/_react.default.createElement("g", { + })) : height > 0 && dataload.value && dataload.value >= 0 && + /*#__PURE__*/ + // default colored bar + _react.default.createElement("g", { transform: "translate(".concat(xScaleValue, ", ").concat(yScaleValue, ")") }, /*#__PURE__*/_react.default.createElement("defs", null, /*#__PURE__*/_react.default.createElement("linearGradient", { id: "gradient", @@ -36559,7 +36093,7 @@ var EcogestureService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context.t1); throw _context.t1; case 40: @@ -36644,7 +36178,7 @@ var EcogestureService = /*#__PURE__*/function () { _logger.default.error(_errorMessage); - Sentry.captureException(_errorMessage); + Sentry.captureException(_context.t3); throw _context.t3; case 78: @@ -36848,7 +36382,7 @@ var EcogestureService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context4.t1); throw _context4.t1; case 31: @@ -36932,7 +36466,7 @@ var EcogestureService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context5.t1); throw _context5.t1; case 31: @@ -37545,7 +37079,7 @@ var TermsService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context5.t0); throw _context5.t0; case 16: @@ -38972,7 +38506,7 @@ exports.default = void 0; var _regenerator = _interopRequireDefault(__webpack_require__("o0o1")); -var _toConsumableArray2 = _interopRequireDefault(__webpack_require__("RIqP")); +var _slicedToArray2 = _interopRequireDefault(__webpack_require__("J4zp")); var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__("yXPU")); @@ -38984,6 +38518,8 @@ var _defineProperty2 = _interopRequireDefault(__webpack_require__("lSNA")); var Sentry = _interopRequireWildcard(__webpack_require__("agHs")); +var _cozyClient = __webpack_require__("SH7X"); + var _cozyLogger = _interopRequireDefault(__webpack_require__("Vggm")); var _challengeEntity2 = _interopRequireDefault(__webpack_require__("+LQo")); @@ -38998,8 +38534,6 @@ var _quizEntity2 = _interopRequireDefault(__webpack_require__("lMoa")); var _doctypes = __webpack_require__("D2hQ"); -var _enums = __webpack_require__("gnxY"); - var _luxon = __webpack_require__("ExVU"); var _migration = __webpack_require__("mfVY"); @@ -39030,10 +38564,6 @@ var _hash = __webpack_require__("C6hV"); var _logger = _interopRequireDefault(__webpack_require__("gjtA")); -var _environment = _interopRequireDefault(__webpack_require__("X6DI")); - -var _fluidsPrices = _interopRequireDefault(__webpack_require__("VjcQ")); - var _profileEcogesture = _interopRequireDefault(__webpack_require__("4iQs")); var _profileTypeEntity = _interopRequireDefault(__webpack_require__("aypK")); @@ -39147,7 +38677,7 @@ var InitializationService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context.t0); throw _context.t0; case 35: @@ -39202,7 +38732,7 @@ var InitializationService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context2.t0); throw _context2.t0; case 18: @@ -39250,7 +38780,7 @@ var InitializationService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context3.t0); throw _context3.t0; case 18: @@ -39271,95 +38801,39 @@ var InitializationService = /*#__PURE__*/function () { key: "initFluidPrices", value: function () { var _initFluidPrices = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() { - var startTime, fpService, loadedPrices, fluidTypes, allPrices, env, remoteUrl, _i, _fluidTypes, fluid, prices, _i2, _allPrices, price, errorMessage; + var startTime, triggerQuery, _yield$this$_client$q, _yield$this$_client$q2, trigger; return _regenerator.default.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: startTime = performance.now(); - fpService = new _fluidsPrices.default(this._client); // Populate data if none ecogesture exists - - _context4.next = 4; - return fpService.getAllPrices(); - - case 4: - loadedPrices = _context4.sent; - - if (!(loadedPrices !== null && loadedPrices !== void 0 && loadedPrices.length)) { - _context4.next = 10; - break; - } - - (0, _duration.logDuration)('[Initialization] FluidPrices db already created', startTime); - return _context4.abrupt("return", true); - - case 10: - _context4.prev = 10; - fluidTypes = [_enums.FluidType.ELECTRICITY, _enums.FluidType.WATER, _enums.FluidType.GAS]; - allPrices = []; - env = new _environment.default(); - remoteUrl = env.isProduction() ? _doctypes.REMOTE_ORG_ECOLYO_AGENT_PRICES : _doctypes.REMOTE_ORG_ECOLYO_AGENT_PRICES_REC; - _i = 0, _fluidTypes = fluidTypes; - - case 16: - if (!(_i < _fluidTypes.length)) { - _context4.next = 25; - break; - } - - fluid = _fluidTypes[_i]; - _context4.next = 20; - return this._client.getStackClient().fetchJSON('GET', "".concat(remoteUrl, "?fluidtype=").concat(fluid)); - - case 20: - prices = _context4.sent; - allPrices.push.apply(allPrices, (0, _toConsumableArray2.default)(prices)); + (0, _duration.logDuration)('[Initialization] Launching fluidPrices service', startTime); + triggerQuery = (0, _cozyClient.Q)(_doctypes.TRIGGERS_DOCTYPE).where({ + 'message.name': 'fluidsPrices' + }); + _context4.next = 5; + return this._client.query(triggerQuery); - case 22: - _i++; - _context4.next = 16; - break; + case 5: + _yield$this$_client$q = _context4.sent; + _yield$this$_client$q2 = (0, _slicedToArray2.default)(_yield$this$_client$q.data, 1); + trigger = _yield$this$_client$q2[0]; - case 25: - _i2 = 0, _allPrices = allPrices; + if (trigger !== null && trigger !== void 0 && trigger._id) { + this._client.getStackClient().fetchJSON('POST', "/jobs/triggers/".concat(trigger._id, "/launch")); - case 26: - if (!(_i2 < _allPrices.length)) { - _context4.next = 33; - break; + (0, _duration.logDuration)('[Initialization] fluidPrices service launched successfully', startTime); + } else { + (0, _duration.logDuration)('[Initialization] FluidPrices service trigger not found', startTime); } - price = _allPrices[_i2]; - _context4.next = 30; - return fpService.createPrice(price); - - case 30: - _i2++; - _context4.next = 26; - break; - - case 33: - (0, _duration.logDuration)('[Initialization] FluidPrices db created', startTime); - return _context4.abrupt("return", true); - - case 37: - _context4.prev = 37; - _context4.t0 = _context4["catch"](10); - errorMessage = "Initialization error - initFluidPrices: ".concat(JSON.stringify(_context4.t0)); - logStack('error', errorMessage); - - _logger.default.error(errorMessage); - - Sentry.captureException(errorMessage); - return _context4.abrupt("return", false); - - case 44: + case 9: case "end": return _context4.stop(); } } - }, _callee4, this, [[10, 37]]); + }, _callee4, this); })); function initFluidPrices() { @@ -39464,7 +38938,7 @@ var InitializationService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context5.t1); throw _context5.t1; case 44: @@ -39546,7 +39020,7 @@ var InitializationService = /*#__PURE__*/function () { _logger.default.error(_errorMessage); - Sentry.captureException(_errorMessage); + Sentry.captureException(_context5.t3); throw _context5.t3; case 83: @@ -39665,7 +39139,7 @@ var InitializationService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context6.t1); throw _context6.t1; case 43: @@ -39747,7 +39221,7 @@ var InitializationService = /*#__PURE__*/function () { _logger.default.error(_errorMessage2); - Sentry.captureException(_errorMessage2); + Sentry.captureException(_context6.t3); throw _context6.t3; case 82: @@ -39866,7 +39340,7 @@ var InitializationService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context7.t1); throw _context7.t1; case 43: @@ -39948,7 +39422,7 @@ var InitializationService = /*#__PURE__*/function () { _logger.default.error(_errorMessage3); - Sentry.captureException(_errorMessage3); + Sentry.captureException(_context7.t3); throw _context7.t3; case 82: @@ -40067,7 +39541,7 @@ var InitializationService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context8.t1); throw _context8.t1; case 43: @@ -40149,7 +39623,7 @@ var InitializationService = /*#__PURE__*/function () { _logger.default.error(_errorMessage4); - Sentry.captureException(_errorMessage4); + Sentry.captureException(_context8.t3); throw _context8.t3; case 82: @@ -40221,7 +39695,7 @@ var InitializationService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context9.t0); throw _context9.t0; case 20: @@ -40292,7 +39766,7 @@ var InitializationService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context10.t0); throw _context10.t0; case 24: @@ -40364,7 +39838,7 @@ var InitializationService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context11.t0); throw _context11.t0; case 24: @@ -40433,7 +39907,7 @@ var InitializationService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context12.t0); throw _context12.t0; case 23: @@ -40493,7 +39967,7 @@ var InitializationService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context13.t0); throw _context13.t0; case 20: @@ -40618,7 +40092,7 @@ var InitializationService = /*#__PURE__*/function () { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(_context14.t0); throw _context14.t0; case 40: diff --git a/index.html b/index.html index ec503d788def9c8e63b9aeb1fbc0db578e524c83..9652e5381e8c0605b890d5f0d5e48887982d66db 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -<!DOCTYPE html><html lang="{{.Locale}}"><head><meta charset="utf-8"><title>Ecolyo</title><link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32"><link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16"><!-- PWA Manifest --><link rel="manifest" href="/manifest.json" crossorigin="use-credentials"><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#297EF2"><meta name="viewport" content="width=device-width,height=device-height,initial-scale=1,viewport-fit=cover"><!-- PWA Chrome --><link rel="icon" sizes="192x192" href="/android-chrome-192x192.png"><link rel="icon" sizes="512x512" href="/android-chrome-512x512.png"><!-- PWA iOS --><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="apple-touch-startup-image" href="/apple-touch-icon.png"><meta name="apple-mobile-web-app-title" content="Ecolyo"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black"><!-- PWA Colors --><meta name="theme-color" content="#343641"><meta name="background-color" content="#121212">{{.ThemeCSS}} {{.CozyBar}}<script src="//{{.Domain}}/assets/js/piwik.js"></script></head><body><div role="application" class="application" data-cozy="{{.CozyData}}"><script src="vendors/ecolyo.c10fac216b392b151e4c.js"></script><script src="app/ecolyo.6cfa06565ced67bf5184.js"></script></div></body></html> \ No newline at end of file +<!DOCTYPE html><html lang="{{.Locale}}"><head><meta charset="utf-8"><title>Ecolyo</title><link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32"><link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16"><!-- PWA Manifest --><link rel="manifest" href="/manifest.json" crossorigin="use-credentials"><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#297EF2"><meta name="viewport" content="width=device-width,height=device-height,initial-scale=1,viewport-fit=cover"><!-- PWA Chrome --><link rel="icon" sizes="192x192" href="/android-chrome-192x192.png"><link rel="icon" sizes="512x512" href="/android-chrome-512x512.png"><!-- PWA iOS --><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="apple-touch-startup-image" href="/apple-touch-icon.png"><meta name="apple-mobile-web-app-title" content="Ecolyo"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black"><!-- PWA Colors --><meta name="theme-color" content="#343641"><meta name="background-color" content="#121212">{{.ThemeCSS}} {{.CozyBar}}<script src="//{{.Domain}}/assets/js/piwik.js"></script></head><body><div role="application" class="application" data-cozy="{{.CozyData}}"><script src="vendors/ecolyo.fbf1f65c47dc10085503.js"></script><script src="app/ecolyo.284c5548bdf91c564a24.js"></script></div></body></html> \ No newline at end of file diff --git a/services/aggregatorUsageEvents/ecolyo.js b/services/aggregatorUsageEvents/ecolyo.js index e5593bae16b8ad0f388dccf3861453025ae791b3..7649dc31f946bd202063656f5f3b4705a9e9ab7b 100644 --- a/services/aggregatorUsageEvents/ecolyo.js +++ b/services/aggregatorUsageEvents/ecolyo.js @@ -158,9 +158,7 @@ const sendIndicator = async (indicator, client) => { } logStack('error', `Error while sending indicator ${indicator.measureName} to remote doctype: ${errorMessage}`); - Sentry.captureException(JSON.stringify({ - error - })); + Sentry.captureException(error); throw error; } }; @@ -1251,9 +1249,7 @@ const AggregatorUsageEvents = async ({ error += `${el.doctype}, `; }); logStack('error', error); - Sentry.captureException(JSON.stringify({ - error - })); + Sentry.captureException(error); throw error; } @@ -44959,7 +44955,7 @@ class ChallengeService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); throw error; } } @@ -45008,7 +45004,7 @@ class ChallengeService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); throw error; } } @@ -45045,7 +45041,7 @@ class ChallengeService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); throw error; } } @@ -45242,7 +45238,7 @@ class ChallengeService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); throw error; } } @@ -100716,7 +100712,7 @@ class DuelService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); throw error; } } @@ -101968,7 +101964,7 @@ class EcogestureService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); throw error; } } // Update if the hash is not the same as the one from profile @@ -102007,7 +102003,7 @@ class EcogestureService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); throw error; } } else { @@ -102090,7 +102086,7 @@ class EcogestureService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); throw error; } } @@ -102114,7 +102110,7 @@ class EcogestureService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); throw error; } } @@ -103228,7 +103224,7 @@ class AccountService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); throw new Error('Get account failed'); } } @@ -103277,7 +103273,7 @@ class AccountService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); return null; } } @@ -103298,7 +103294,7 @@ class AccountService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); return []; } } @@ -103313,7 +103309,7 @@ class AccountService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); throw new Error('Update account failed'); } } @@ -103328,7 +103324,7 @@ class AccountService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); throw new Error(errorMessage); } } @@ -112350,7 +112346,7 @@ class TriggerService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); throw new Error('Delete trigger failed'); } } @@ -119552,7 +119548,7 @@ class ProfileTypeEntityService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); return false; } } @@ -119704,7 +119700,7 @@ class TermsService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); throw error; } } @@ -119830,7 +119826,7 @@ class UsageEventService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); } } /** @@ -119842,22 +119838,23 @@ class UsageEventService { static async updateUsageEventsAggregated(client, events) { - for (const event of events) { - try { + try { + for (const event of events) { await client.save(_objectSpread(_objectSpread({}, event), {}, { aggregated: true })); - } catch (error) { - const errorMessage = `UsageEvent service error on updateUsageEventsAggregated: ${JSON.stringify(error)}`; - logStack('error', errorMessage); + } - _logger.default.error(errorMessage); + return true; + } catch (error) { + const errorMessage = `UsageEvent service error on updateUsageEventsAggregated: ${JSON.stringify(error)}`; + logStack('error', errorMessage); - Sentry.captureException(errorMessage); - } - } + _logger.default.error(errorMessage); - return true; + Sentry.captureException(error); + throw new Error('Could not update all events'); + } } /** * getEvents diff --git a/services/consumptionAlert/ecolyo.js b/services/consumptionAlert/ecolyo.js index 2b995cdb94fb4740d05fcd72beb57884ce3c6158..68bf198a728b06a9bb745fa1dfdb33fcbca607a7 100644 --- a/services/consumptionAlert/ecolyo.js +++ b/services/consumptionAlert/ecolyo.js @@ -163155,7 +163155,7 @@ class MailService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); throw new Error(errorMessage); } } diff --git a/services/enedisHalfHourMonthlyAnalysis/ecolyo.js b/services/enedisHalfHourMonthlyAnalysis/ecolyo.js index 0129f7e2cfb02da873de14392ad5cc5c27ea69f8..c9bb13f0377cc467990371d17c2f70d81d7db284 100644 --- a/services/enedisHalfHourMonthlyAnalysis/ecolyo.js +++ b/services/enedisHalfHourMonthlyAnalysis/ecolyo.js @@ -99794,7 +99794,7 @@ class EnedisMonthlyAnalysisDataService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); throw error; } } diff --git a/services/fluidsPrices/ecolyo.js b/services/fluidsPrices/ecolyo.js index a56f95ba7b09b24284640c2e33d74b21b71af4de..044fa2918f2ff32d1e5ee2a8159302c7c4d830a9 100644 --- a/services/fluidsPrices/ecolyo.js +++ b/services/fluidsPrices/ecolyo.js @@ -99461,64 +99461,49 @@ const synchroPricesToUpdate = async (client, fluidType) => { const fps = new _fluidsPrices.default(client); const remotePrices = await getRemotePricesByFluid(client, fluidType); let firstEditedPrice = null; - await Promise.all(remotePrices.map(remotePrice => { - // eslint-disable-next-line no-async-promise-executor - return new Promise(async resolve => { - try { - // Check if price exist in database - const existingPrice = await fps.checkIfPriceExists(remotePrice); - - if (existingPrice) { - // Check if the remote price is more recent - if (existingPrice.UpdatedAt && remotePrice.UpdatedAt && existingPrice.UpdatedAt < remotePrice.UpdatedAt) { - logStack('debug', `Price exist in db but not up to date, updating it`); // If a price has been updated, set the oldest startDate of the edited price so we can redo aggregation + await Promise.all(remotePrices.map(async remotePrice => { + try { + const existingPrice = await fps.checkIfPriceExists(remotePrice); - if (firstEditedPrice === null) { - firstEditedPrice = remotePrice.startDate; - } + if (!existingPrice) { + logStack('debug', `Price doesn't exist in db, creating a new price`); // If a price has been updated, set the oldest startDate of the edited price so we can redo aggregation - if (firstEditedPrice >= remotePrice.startDate) { - firstEditedPrice = remotePrice.startDate; - } // update this price in db + if (firstEditedPrice === null || firstEditedPrice >= remotePrice.startDate) { + firstEditedPrice = remotePrice.startDate; + } + await fps.createPrice(remotePrice); + return; + } - await fps.updatePrice(existingPrice, { - price: remotePrice.price, - UpdatedAt: remotePrice.UpdatedAt, - startDate: remotePrice.startDate, - endDate: remotePrice.endDate - }); - } else if (!existingPrice.UpdatedAt && remotePrice.UpdatedAt) { - // updatedAt key doesn't exist in db - await fps.updatePrice(existingPrice, { - UpdatedAt: remotePrice.UpdatedAt - }); - } else { - logStack('debug', `Price up to date`); - } - } else { - logStack('debug', `Price doesn't exist in db, creating new price`); // If a price has been updated, set the oldest startDate of the edited price so we can redo aggregation + if (!existingPrice.UpdatedAt && remotePrice.UpdatedAt) { + // updatedAt key doesn't exist in db + await fps.updatePrice(existingPrice, { + UpdatedAt: remotePrice.UpdatedAt + }); + return; + } else if (!existingPrice.UpdatedAt || !remotePrice.UpdatedAt || existingPrice.UpdatedAt >= remotePrice.UpdatedAt) { + logStack('debug', `Price up to date`); + return; + } - if (firstEditedPrice === null) { - firstEditedPrice = remotePrice.startDate; - } + logStack('debug', `Price exists in db but not up to date, updating it`); // If a price has been updated, set the oldest startDate of the edited price so we can redo aggregation - if (firstEditedPrice >= remotePrice.startDate) { - firstEditedPrice = remotePrice.startDate; - } // create price in db + if (firstEditedPrice === null || firstEditedPrice >= remotePrice.startDate) { + firstEditedPrice = remotePrice.startDate; + } // update this price in db - await fps.createPrice(remotePrice); - } - } catch (error) { - logStack('error', `Error: ${error}`); - Sentry.captureException(JSON.stringify({ - error - })); - } finally { - resolve(); - } - }); + await fps.updatePrice(existingPrice, { + price: remotePrice.price, + UpdatedAt: remotePrice.UpdatedAt, + startDate: remotePrice.startDate, + endDate: remotePrice.endDate + }); + } catch (error) { + logStack('error', `Error: ${error}`); + Sentry.captureException(error); + } })); return firstEditedPrice; }; @@ -99567,46 +99552,39 @@ const aggregatePrices = async (qr, cdm, firstDate, today, fluidType) => { const tsa = [_enums.TimeStep.MONTH, _enums.TimeStep.YEAR]; logStack('debug', `Aggregation started for fluid: ${fluidType}, from ${firstDate} `); await Promise.all(tsa.map(async ts => { - // eslint-disable-next-line no-async-promise-executor - return new Promise(async resolve => { - let date = _luxon.DateTime.local(); + let date = _luxon.DateTime.local(); - Object.assign(date, firstDate); + Object.assign(date, firstDate); - try { - do { - const tp = await getTimePeriod(ts, date); // Get doc for aggregation + try { + do { + const tp = await getTimePeriod(ts, date); // Get doc for aggregation - const data = await qr.fetchFluidRawDoctype(tp, _enums.TimeStep.DAY, fluidType); // Get doc to update + const data = await qr.fetchFluidRawDoctype(tp, _enums.TimeStep.DAY, fluidType); // Get doc to update - const docToUpdate = await qr.fetchFluidRawDoctype(tp, ts, fluidType); + const docToUpdate = await qr.fetchFluidRawDoctype(tp, ts, fluidType); - if (docToUpdate !== null && docToUpdate !== void 0 && docToUpdate.data && data !== null && data !== void 0 && data.data) { - docToUpdate.data[0].price = data.data.map(price).reduce(sum); - } // Save updated docs + if (docToUpdate !== null && docToUpdate !== void 0 && docToUpdate.data && data !== null && data !== void 0 && data.data) { + docToUpdate.data[0].price = data.data.map(price).reduce(sum); + } // Save updated docs - await cdm.saveDocs(docToUpdate.data); // Update date according to timestep + await cdm.saveDocs(docToUpdate === null || docToUpdate === void 0 ? void 0 : docToUpdate.data); // Update date according to timestep - if (ts === _enums.TimeStep.YEAR) { - date = date.plus({ - year: 1 - }).startOf('month'); - } else { - date = date.plus({ - month: 1 - }).startOf('month'); - } - } while (date < today); - } catch (error) { - logStack('info', `Error : ${error}`); - Sentry.captureException(JSON.stringify({ - error - })); - } finally { - resolve(); - } - }); + if (ts === _enums.TimeStep.YEAR) { + date = date.plus({ + year: 1 + }).startOf('month'); + } else { + date = date.plus({ + month: 1 + }).startOf('month'); + } + } while (date < today); + } catch (error) { + logStack('info', `Error : ${error}`); + Sentry.captureException(error); + } })); logStack('debug', `Aggregation done`); }; @@ -99702,53 +99680,46 @@ const applyPrices = async (client, fluidType) => { await Promise.all(tsa.map(async timeStep => { - // eslint-disable-next-line no-async-promise-executor - return new Promise(async resolve => { - let date = _luxon.DateTime.local().setZone('utc', { - keepLocalTime: true - }); + let date = _luxon.DateTime.local().setZone('utc', { + keepLocalTime: true + }); - Object.assign(date, firstDate); + Object.assign(date, firstDate); - try { - do { - // Get price - const priceData = await fluidsPricesService.getPrices(fluidType, date); - const tp = await getTimePeriod(timeStep, date); // Get doc to update + try { + do { + // Get price + const priceData = await fluidsPricesService.getPrices(fluidType, date); + const tp = await getTimePeriod(timeStep, date); // Get doc to update - const data = await qr.fetchFluidRawDoctype(tp, timeStep, fluidType); // If lastItem has a price, skip this day (in order to save perf) + const data = await qr.fetchFluidRawDoctype(tp, timeStep, fluidType); // If lastItem has a price, skip this day (in order to save perf) - const lastItem = (data === null || data === void 0 ? void 0 : data.data) && data.data[data.data.length - 1]; + const lastItem = (data === null || data === void 0 ? void 0 : data.data) && data.data[data.data.length - 1]; - if (lastItem && priceData) { - // if a price has been updated in backoffice re-calculates all price from the firstEditedPriceDate - data === null || data === void 0 ? void 0 : data.data.forEach(element => { - element.price = element.load * priceData.price; - }); // Save updated docs + if (lastItem && priceData) { + // if a price has been updated in backoffice re-calculates all price from the firstEditedPriceDate + data === null || data === void 0 ? void 0 : data.data.forEach(element => { + element.price = element.load * priceData.price; + }); // Save updated docs - await cdm.saveDocs(data.data); - } // Update date + await cdm.saveDocs(data.data); + } // Update date - if (timeStep === _enums.TimeStep.HALF_AN_HOUR) { - date = date.plus({ - days: 1 - }); - } else { - date = date.plus({ - month: 1 - }).startOf('month'); - } - } while (date < today); - } catch (error) { - logStack('error', `ERROR : ${error} `); - Sentry.captureException(JSON.stringify({ - error - })); - } finally { - resolve(); - } - }); + if (timeStep === _enums.TimeStep.HALF_AN_HOUR) { + date = date.plus({ + days: 1 + }); + } else { + date = date.plus({ + month: 1 + }).startOf('month'); + } + } while (date < today); + } catch (error) { + logStack('error', `ERROR : ${error} `); + Sentry.captureException(error); + } })); // Call aggregation method await aggregatePrices(qr, cdm, firstDate, today, fluidType); @@ -99918,7 +99889,7 @@ class FluidPricesService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); return false; } } @@ -99962,7 +99933,7 @@ class FluidPricesService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); throw error; } } diff --git a/services/monthlyReportNotification/ecolyo.js b/services/monthlyReportNotification/ecolyo.js index b87911b2851030611094bd88f3f6af2601ca4965..87efa452edf19a0a31f4ee0213015609b4c1f417 100644 --- a/services/monthlyReportNotification/ecolyo.js +++ b/services/monthlyReportNotification/ecolyo.js @@ -163045,7 +163045,7 @@ class MailService { _logger.default.error(errorMessage); - Sentry.captureException(errorMessage); + Sentry.captureException(error); throw new Error(errorMessage); } } @@ -164739,9 +164739,7 @@ const getMonthlyReport = async (year, month, client) => { return result; } catch (error) { logStack('error', JSON.stringify(error)); - Sentry.captureException(JSON.stringify({ - error - })); + Sentry.captureException(error); return { year: parseInt(year), month: parseInt(month), @@ -164780,9 +164778,7 @@ const monthlyReportNotification = async ({ }); } catch (error) { logStack('error', 'Update mailToken user profile error : ' + error); - Sentry.captureException(JSON.stringify({ - error - })); + Sentry.captureException(error); throw error; } } diff --git a/vendors/ecolyo.c10fac216b392b151e4c.js b/vendors/ecolyo.fbf1f65c47dc10085503.js similarity index 99% rename from vendors/ecolyo.c10fac216b392b151e4c.js rename to vendors/ecolyo.fbf1f65c47dc10085503.js index 9ec5abef065f1d9b582e8efcd81caa7860558068..94600eeac13e1abccbd7fb9bda96774b1686f8ee 100644 --- a/vendors/ecolyo.c10fac216b392b151e4c.js +++ b/vendors/ecolyo.fbf1f65c47dc10085503.js @@ -120616,7 +120616,7 @@ module.exports = _typeof; "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "severityFromString", function() { return severityFromString; }); -/* harmony import */ var _sentry_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("USg8"); +/* harmony import */ var _sentry_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("PIsB"); /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("FbLj"); @@ -233743,22 +233743,6 @@ exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) || /***/ }), -/***/ "USg8": -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _severity__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("nDts"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Severity", function() { return _severity__WEBPACK_IMPORTED_MODULE_0__["Severity"]; }); - -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SeverityLevels", function() { return _severity__WEBPACK_IMPORTED_MODULE_0__["SeverityLevels"]; }); - - - -//# sourceMappingURL=index.js.map - -/***/ }), - /***/ "USxY": /***/ (function(module, exports, __webpack_require__) { @@ -346409,40 +346393,6 @@ __webpack_require__("7DDg")('Uint32', 4, function (init) { }); -/***/ }), - -/***/ "nDts": -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Severity", function() { return Severity; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SeverityLevels", function() { return SeverityLevels; }); -/** - * TODO(v7): Remove this enum and replace with SeverityLevel - */ -var Severity; -(function (Severity) { - /** JSDoc */ - Severity["Fatal"] = "fatal"; - /** JSDoc */ - Severity["Error"] = "error"; - /** JSDoc */ - Severity["Warning"] = "warning"; - /** JSDoc */ - Severity["Log"] = "log"; - /** JSDoc */ - Severity["Info"] = "info"; - /** JSDoc */ - Severity["Debug"] = "debug"; - /** JSDoc */ - Severity["Critical"] = "critical"; -})(Severity || (Severity = {})); -// TODO: in v7, these can disappear, because they now also exist in `@sentry/utils`. (Having them there rather than here -// is nice because then it enforces the idea that only types are exported from `@sentry/types`.) -var SeverityLevels = ['fatal', 'error', 'warning', 'log', 'info', 'debug', 'critical']; -//# sourceMappingURL=severity.js.map - /***/ }), /***/ "nE4i":