@qrvey/utils 1.8.0-3 → 1.8.0-4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.8.0-3*
1
+ # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.8.0-4*
2
2
 
3
3
  > Helper, Utils for all Qrvey Projects
4
4
 
@@ -1,7 +1,20 @@
1
- import { MetricConfig, MetricRequestPayload } from "../interfaces/IRequestAdapterMetric";
1
+ import { IBColumn } from "../../columns";
2
+ import { CustomRangeConfig, MetricConfig, MetricCustomRange, MetricPeriod, MetricRequestPayload, MetricTimeInfo } from "../interfaces/IRequestAdapterMetric";
2
3
  /**
3
4
  * It takes a metric object and returns a metric request object
4
5
  * @param {MetricConfig} metricObj - MetricConfigData
5
6
  * @returns A function that takes in a metricObj and returns a partial metricRequest
6
7
  */
7
8
  export declare const makeBodyRequestMetrics: (metricObj: MetricConfig) => Partial<MetricRequestPayload>;
9
+ /**
10
+ * It takes a date column, time data, and a custom range config and returns a metric period or metric
11
+ * custom range
12
+ * @param dateColumn - The column that contains the date data.
13
+ * @param timeData - {
14
+ * @param {CustomRangeConfig} range - CustomRangeConfig
15
+ * @returns An object with the following properties:
16
+ * - label
17
+ * - value
18
+ * - questionid
19
+ */
20
+ export declare const metricMakeTimeData: (dateColumn: IBColumn, timeData: MetricTimeInfo, range: CustomRangeConfig) => MetricPeriod | MetricCustomRange;
@@ -53,7 +53,7 @@ const isComparison = (data) => Boolean(data === null || data === void 0 ? void 0
53
53
  * - value
54
54
  * - questionid
55
55
  */
56
- const metricMakeTimeData = (dateColumn, timeData, range) => {
56
+ export const metricMakeTimeData = (dateColumn, timeData, range) => {
57
57
  const relativObject = getConfigRelativeObjectBytimeLabel(timeData.label, range);
58
58
  if (!isEmpty(relativObject))
59
59
  return Object.assign(Object.assign({}, relativObject), { questionid: dateColumn.id });
@@ -83,7 +83,7 @@ const makeCustomRangeConfig = (customRangeData) => {
83
83
  return { gte: startingDate };
84
84
  if (label === TP_CUSTOM_RANGE.BEFORE && !isEmpty(startingDate))
85
85
  return { lte: startingDate };
86
- if (!isEmpty(startingDate) && !isEmpty(endDate))
86
+ if (!isEmpty(startingDate) || !isEmpty(endDate))
87
87
  return { gte: startingDate, lte: endDate };
88
88
  };
89
89
  /**
@@ -1,7 +1,20 @@
1
- import { MetricConfig, MetricRequestPayload } from "../interfaces/IRequestAdapterMetric";
1
+ import { IBColumn } from "../../columns";
2
+ import { CustomRangeConfig, MetricConfig, MetricCustomRange, MetricPeriod, MetricRequestPayload, MetricTimeInfo } from "../interfaces/IRequestAdapterMetric";
2
3
  /**
3
4
  * It takes a metric object and returns a metric request object
4
5
  * @param {MetricConfig} metricObj - MetricConfigData
5
6
  * @returns A function that takes in a metricObj and returns a partial metricRequest
6
7
  */
7
8
  export declare const makeBodyRequestMetrics: (metricObj: MetricConfig) => Partial<MetricRequestPayload>;
9
+ /**
10
+ * It takes a date column, time data, and a custom range config and returns a metric period or metric
11
+ * custom range
12
+ * @param dateColumn - The column that contains the date data.
13
+ * @param timeData - {
14
+ * @param {CustomRangeConfig} range - CustomRangeConfig
15
+ * @returns An object with the following properties:
16
+ * - label
17
+ * - value
18
+ * - questionid
19
+ */
20
+ export declare const metricMakeTimeData: (dateColumn: IBColumn, timeData: MetricTimeInfo, range: CustomRangeConfig) => MetricPeriod | MetricCustomRange;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeBodyRequestMetrics = void 0;
3
+ exports.metricMakeTimeData = exports.makeBodyRequestMetrics = void 0;
4
4
  const general_1 = require("../../general");
5
5
  const interfaces_1 = require("../../interfaces");
6
6
  const REQUEST_ADAPTER_1 = require("../constants/REQUEST_ADAPTER");
@@ -17,8 +17,8 @@ const makeBodyRequestMetrics = (metricObj) => {
17
17
  /* Checking if the data object has a dateColumn property. If it does, it will add a period and
18
18
  comparison property to the body object. */
19
19
  if (isComparison(data)) {
20
- body.period = metricMakeTimeData(data.dateColumn, data.timePeriod, getRangeDataPeriod(data));
21
- body.comparison = metricMakeTimeData(data.dateColumn, data.comparison, getRangeDataComparison(data));
20
+ body.period = (0, exports.metricMakeTimeData)(data.dateColumn, data.timePeriod, getRangeDataPeriod(data));
21
+ body.comparison = (0, exports.metricMakeTimeData)(data.dateColumn, data.comparison, getRangeDataComparison(data));
22
22
  }
23
23
  return body;
24
24
  };
@@ -62,6 +62,7 @@ const metricMakeTimeData = (dateColumn, timeData, range) => {
62
62
  if (!(0, general_1.isEmpty)(relativObject))
63
63
  return Object.assign(Object.assign({}, relativObject), { questionid: dateColumn.id });
64
64
  };
65
+ exports.metricMakeTimeData = metricMakeTimeData;
65
66
  /**
66
67
  * Given a time label and a custom range, return a relative date config or a metric custom range.
67
68
  * @param {TIME_PERIOD} timeLabel - TIME_PERIOD.CUSTOM_RANGE
@@ -87,7 +88,7 @@ const makeCustomRangeConfig = (customRangeData) => {
87
88
  return { gte: startingDate };
88
89
  if (label === interfaces_1.TP_CUSTOM_RANGE.BEFORE && !(0, general_1.isEmpty)(startingDate))
89
90
  return { lte: startingDate };
90
- if (!(0, general_1.isEmpty)(startingDate) && !(0, general_1.isEmpty)(endDate))
91
+ if (!(0, general_1.isEmpty)(startingDate) || !(0, general_1.isEmpty)(endDate))
91
92
  return { gte: startingDate, lte: endDate };
92
93
  };
93
94
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.8.0-3",
3
+ "version": "1.8.0-4",
4
4
  "description": "Helper, Utils for all Qrvey Projects",
5
5
  "homepage": "https://bitbucket.org/qrvey/qrvey_utils/wiki/Home",
6
6
  "main": "dist/index.js",