UNPKG

historical-deadletter-processor

Version:
94 lines (71 loc) 4.41 kB
"use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Generated by CoffeeScript 2.7.0 (function () { var AbstractReaderProcessor, AzureSearch, CleanupProcessor, HighlandPagination, Promise, _, debug, highland, moment, boundMethodCheck = function boundMethodCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new Error('Bound instance method accessed before binding'); } }; _ = require("lodash"); Promise = require("bluebird"); highland = require("highland"); AzureSearch = require("azure-search"); HighlandPagination = require("highland-pagination"); moment = require("moment"); debug = require("debug")("historical-deadletter:cleanup"); require("highland-concurrent-flatmap"); moment = require("moment"); AbstractReaderProcessor = require("./abstract.reader.processor"); module.exports = CleanupProcessor = function (_AbstractReaderProces) { _inherits(CleanupProcessor, _AbstractReaderProces); function CleanupProcessor(opts) { _classCallCheck(this, CleanupProcessor); var _this = _possibleConstructorReturn(this, (CleanupProcessor.__proto__ || Object.getPrototypeOf(CleanupProcessor)).call(this, _.defaults(opts, { sizePage: 1000 }))); _this._filter_ = _this._filter_.bind(_this); _this._queryOptions_ = _this._queryOptions_.bind(_this); var _opts$days = opts.days; _this.days = _opts$days === undefined ? 30 : _opts$days; return _this; } _createClass(CleanupProcessor, [{ key: "_action_", value: function _action_(stream) { return stream; } }, { key: "_filter_", value: function _filter_() { var page = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; var nDaysAgo; boundMethodCheck(this, CleanupProcessor); nDaysAgo = moment().subtract(this.days, 'days').startOf('day').utc().format("YYYY-MM-DDTHH:mm:ss") + "z"; return "timestamp lt " + nDaysAgo; } }, { key: "_queryOptions_", value: function _queryOptions_() { boundMethodCheck(this, CleanupProcessor); return _.merge(_get(CleanupProcessor.prototype.__proto__ || Object.getPrototypeOf(CleanupProcessor.prototype), "_queryOptions_", this).call(this), { select: "id" }); } }]); return CleanupProcessor; }(AbstractReaderProcessor); }).call(undefined);