UNPKG

@golemio/parkings

Version:
37 lines 2.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SaveTskParkingSectionLevelTask = void 0; const TskParkingFilter_1 = require("../../transformations/TskParkingFilter"); const UpdateAddressWorker_1 = require("../UpdateAddressWorker"); const integration_engine_1 = require("@golemio/core/dist/integration-engine"); const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors"); class SaveTskParkingSectionLevelTask extends integration_engine_1.AbstractEmptyTask { constructor(queueName, queuePrefix, dataSource, transformation, parkingsLocationRepository, config) { super(queuePrefix); this.queueName = queueName; this.dataSource = dataSource; this.transformation = transformation; this.parkingsLocationRepository = parkingsLocationRepository; this.config = config; } async execute() { try { const sourceData = await this.dataSource.getAll(); const filteredData = sourceData.filter((parking) => TskParkingFilter_1.TskParkingFilter.isWithinValidityPeriod(parking)); const parkingLocations = this.transformation.transformArray(filteredData); // The task runs twice with different values for the "specialAccess" transformation parameter const includeDisabled = !!this.transformation["specialAccess"]; await this.parkingsLocationRepository.saveTskParkingLocations(parkingLocations, includeDisabled); const exchange = this.config.getValue("env.RABBIT_EXCHANGE_NAME"); await integration_engine_1.QueueManager.sendMessageToExchange(exchange + "." + UpdateAddressWorker_1.UpdateAddressWorker.workerName.toLowerCase(), "updateMissingParkingsLocationAddresses", {}); } catch (error) { if (error instanceof golemio_errors_1.AbstractGolemioError) { throw error; } throw new golemio_errors_1.GeneralError("Error while saving TSK parking section levels", this.constructor.name, error); } } } exports.SaveTskParkingSectionLevelTask = SaveTskParkingSectionLevelTask; //# sourceMappingURL=SaveTskParkingSectionLevelTask.js.map