Skip to content

Commit

Permalink
chore(build): bundle library for v0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMaruchu committed Sep 19, 2019
1 parent 180fea6 commit f81c2c2
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 31 deletions.
69 changes: 53 additions & 16 deletions es/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { pkg } from '@lykmapipo/common';
import { head, merge, map, pick, isEmpty, upperFirst, omit, isNumber } from 'lodash';
import { head, merge, map, pick, isEmpty, upperFirst, omit, isNumber, compact } from 'lodash';
import { Router } from '@lykmapipo/express-common';
import { getString } from '@lykmapipo/env';
import { model } from '@lykmapipo/mongoose-common';
Expand Down Expand Up @@ -848,7 +848,7 @@ const OVERVIEW_FACET = {
* @param {object} onResults Callback when aggregation operation finishes
* @returns {object} executed aggregation
*
* @version 0.1.0
* @version 0.2.0
* @since 0.1.0
*
* @example
Expand Down Expand Up @@ -899,21 +899,24 @@ const PERFORMANCE_FACET = {
* @description Generate performance report based on provided criteria
*
* @param {object} criteria Criteria condition to be applied in $match
* @param {string[]} facetKeys Contain list of facets key to be used to generate report
* @param {object} onResults Callback when aggregation operation finishes
* @returns {object} executed aggregation
*
* @version 0.1.0
* @version 0.2.0
* @since 0.1.0
*
* @example
* getPerformanceReport(criteria, function(error, data){
* ...
* });
*/
const getPerformanceReport = (criteria, onResults) => {
const getPerformanceReport = (criteria, facetKeys, onResults) => {
const baseAggregation = getBaseAggregation(criteria);

return baseAggregation.facet(PERFORMANCE_FACET).exec(onResults);
const FACET = getFacet(PERFORMANCE_FACET, facetKeys);

return baseAggregation.facet(FACET).exec(onResults);
};

/**
Expand Down Expand Up @@ -942,21 +945,24 @@ const OPERATOR_PERFORMANCE_FACET = {
* @description Generate operator performance report based on provided criteria
*
* @param {object} criteria Criteria condition to be applied in $match
* @param {string[]} facetKeys Contain list of facets key to be used to generate report
* @param {object} onResults Callback when aggregation operation finishes
* @returns {object} executed aggregation
*
* @version 0.1.0
* @version 0.2.0
* @since 0.1.0
*
* @example
* getOperatorPerformanceReport(criteria, function(error, data){
* ...
* });
*/
const getOperatorPerformanceReport = (criteria, onResults) => {
const getOperatorPerformanceReport = (criteria, facetKeys, onResults) => {
const baseAggregation = getBaseAggregation(criteria);

return baseAggregation.facet(OPERATOR_PERFORMANCE_FACET).exec(onResults);
const FACET = getFacet(OPERATOR_PERFORMANCE_FACET, facetKeys);

return baseAggregation.facet(FACET).exec(onResults);
};

/**
Expand Down Expand Up @@ -989,21 +995,24 @@ const OPERATIONAL_FACET = {
* @description Generate operational report based on provided criteria
*
* @param {object} criteria Criteria condition to be applied in $match
* @param {string[]} facetKeys Contain list of facets key to be used to generate report
* @param {object} onResults Callback when aggregation operation finishes
* @returns {object} executed aggregation
*
* @version 0.1.0
* @version 0.2.0
* @since 0.1.0
*
* @example
* getOperationalReport(criteria, function(error, data){
* ...
* });
*/
const getOperationalReport = (criteria, onResults) => {
const getOperationalReport = (criteria, facetKeys, onResults) => {
const baseAggregation = getBaseAggregation(criteria);

return baseAggregation.facet(OPERATIONAL_FACET).exec(onResults);
const FACET = getFacet(OPERATIONAL_FACET, facetKeys);

return baseAggregation.facet(FACET).exec(onResults);
};

/* eslint-disable jsdoc/check-tag-names */
Expand Down Expand Up @@ -1040,9 +1049,13 @@ router.get(PATH_OVERVIEW, (request, response, next) => {

const filter = options.filter || {};

const facets = options.facets || [];
const { facets } = request.query;

let facetKeys = [];

const facetKeys = [].concat(facets);
if (!isEmpty(facets)) {
facetKeys = compact([].concat(facets.split(',')));
}

getOverviewReport(filter, facetKeys, (error, results) => {
if (error) {
Expand Down Expand Up @@ -1076,7 +1089,15 @@ router.get(PATH_PERFORMANCE, (request, response, next) => {

const filter = options.filter || {};

getPerformanceReport(filter, (error, results) => {
const { facets } = request.query;

let facetKeys = [];

if (!isEmpty(facets)) {
facetKeys = compact([].concat(facets.split(',')));
}

getPerformanceReport(filter, facetKeys, (error, results) => {
if (error) {
next(error);
} else {
Expand Down Expand Up @@ -1110,7 +1131,15 @@ router.get(PATH_OPERATOR_PERFORMANCE, (request, response, next) => {

const filter = options.filter || {};

getOperatorPerformanceReport(filter, (error, results) => {
const { facets } = request.query;

let facetKeys = [];

if (!isEmpty(facets)) {
facetKeys = compact([].concat(facets.split(',')));
}

getOperatorPerformanceReport(filter, facetKeys, (error, results) => {
if (error) {
next(error);
} else {
Expand Down Expand Up @@ -1142,7 +1171,15 @@ router.get(PATH_OPERATIONAL, (request, response, next) => {

const filter = options.filter || {};

getOperationalReport(filter, (error, results) => {
const { facets } = request.query;

let facetKeys = [];

if (!isEmpty(facets)) {
facetKeys = compact([].concat(facets.split(',')));
}

getOperationalReport(filter, facetKeys, (error, results) => {
if (error) {
next(error);
} else {
Expand Down
67 changes: 52 additions & 15 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ const OVERVIEW_FACET = {
* @param {object} onResults Callback when aggregation operation finishes
* @returns {object} executed aggregation
*
* @version 0.1.0
* @version 0.2.0
* @since 0.1.0
*
* @example
Expand Down Expand Up @@ -901,21 +901,24 @@ const PERFORMANCE_FACET = {
* @description Generate performance report based on provided criteria
*
* @param {object} criteria Criteria condition to be applied in $match
* @param {string[]} facetKeys Contain list of facets key to be used to generate report
* @param {object} onResults Callback when aggregation operation finishes
* @returns {object} executed aggregation
*
* @version 0.1.0
* @version 0.2.0
* @since 0.1.0
*
* @example
* getPerformanceReport(criteria, function(error, data){
* ...
* });
*/
const getPerformanceReport = (criteria, onResults) => {
const getPerformanceReport = (criteria, facetKeys, onResults) => {
const baseAggregation = getBaseAggregation(criteria);

return baseAggregation.facet(PERFORMANCE_FACET).exec(onResults);
const FACET = getFacet(PERFORMANCE_FACET, facetKeys);

return baseAggregation.facet(FACET).exec(onResults);
};

/**
Expand Down Expand Up @@ -944,21 +947,24 @@ const OPERATOR_PERFORMANCE_FACET = {
* @description Generate operator performance report based on provided criteria
*
* @param {object} criteria Criteria condition to be applied in $match
* @param {string[]} facetKeys Contain list of facets key to be used to generate report
* @param {object} onResults Callback when aggregation operation finishes
* @returns {object} executed aggregation
*
* @version 0.1.0
* @version 0.2.0
* @since 0.1.0
*
* @example
* getOperatorPerformanceReport(criteria, function(error, data){
* ...
* });
*/
const getOperatorPerformanceReport = (criteria, onResults) => {
const getOperatorPerformanceReport = (criteria, facetKeys, onResults) => {
const baseAggregation = getBaseAggregation(criteria);

return baseAggregation.facet(OPERATOR_PERFORMANCE_FACET).exec(onResults);
const FACET = getFacet(OPERATOR_PERFORMANCE_FACET, facetKeys);

return baseAggregation.facet(FACET).exec(onResults);
};

/**
Expand Down Expand Up @@ -991,21 +997,24 @@ const OPERATIONAL_FACET = {
* @description Generate operational report based on provided criteria
*
* @param {object} criteria Criteria condition to be applied in $match
* @param {string[]} facetKeys Contain list of facets key to be used to generate report
* @param {object} onResults Callback when aggregation operation finishes
* @returns {object} executed aggregation
*
* @version 0.1.0
* @version 0.2.0
* @since 0.1.0
*
* @example
* getOperationalReport(criteria, function(error, data){
* ...
* });
*/
const getOperationalReport = (criteria, onResults) => {
const getOperationalReport = (criteria, facetKeys, onResults) => {
const baseAggregation = getBaseAggregation(criteria);

return baseAggregation.facet(OPERATIONAL_FACET).exec(onResults);
const FACET = getFacet(OPERATIONAL_FACET, facetKeys);

return baseAggregation.facet(FACET).exec(onResults);
};

/* eslint-disable jsdoc/check-tag-names */
Expand Down Expand Up @@ -1042,9 +1051,13 @@ router.get(PATH_OVERVIEW, (request, response, next) => {

const filter = options.filter || {};

const facets = options.facets || [];
const { facets } = request.query;

let facetKeys = [];

const facetKeys = [].concat(facets);
if (!lodash.isEmpty(facets)) {
facetKeys = lodash.compact([].concat(facets.split(',')));
}

getOverviewReport(filter, facetKeys, (error, results) => {
if (error) {
Expand Down Expand Up @@ -1078,7 +1091,15 @@ router.get(PATH_PERFORMANCE, (request, response, next) => {

const filter = options.filter || {};

getPerformanceReport(filter, (error, results) => {
const { facets } = request.query;

let facetKeys = [];

if (!lodash.isEmpty(facets)) {
facetKeys = lodash.compact([].concat(facets.split(',')));
}

getPerformanceReport(filter, facetKeys, (error, results) => {
if (error) {
next(error);
} else {
Expand Down Expand Up @@ -1112,7 +1133,15 @@ router.get(PATH_OPERATOR_PERFORMANCE, (request, response, next) => {

const filter = options.filter || {};

getOperatorPerformanceReport(filter, (error, results) => {
const { facets } = request.query;

let facetKeys = [];

if (!lodash.isEmpty(facets)) {
facetKeys = lodash.compact([].concat(facets.split(',')));
}

getOperatorPerformanceReport(filter, facetKeys, (error, results) => {
if (error) {
next(error);
} else {
Expand Down Expand Up @@ -1144,7 +1173,15 @@ router.get(PATH_OPERATIONAL, (request, response, next) => {

const filter = options.filter || {};

getOperationalReport(filter, (error, results) => {
const { facets } = request.query;

let facetKeys = [];

if (!lodash.isEmpty(facets)) {
facetKeys = lodash.compact([].concat(facets.split(',')));
}

getOperationalReport(filter, facetKeys, (error, results) => {
if (error) {
next(error);
} else {
Expand Down

0 comments on commit f81c2c2

Please sign in to comment.