Skip to content

Commit

Permalink
Allow number as date (#316)
Browse files Browse the repository at this point in the history
Signed-off-by: Danila Gulderov <[email protected]>
  • Loading branch information
gulderov committed Feb 26, 2024
1 parent d8a2ed3 commit 0e39af9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server/routes/utils/dataReportHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const getOpenSearchData = (
// if its not a nested date field
if (keys.length === 1) {
// if conditions to determine if the date field's value is an array or a string
if (typeof dateValue === 'string') {
if (typeof dateValue === 'string' || typeof dateValue === 'number') {
data._source[keys] = moment.utc(dateValue).tz(timezone).format(dateFormat);
} else if (
dateValue.length !== 0 &&
Expand All @@ -158,7 +158,7 @@ export const getOpenSearchData = (
} else {
let keyElement = keys.shift();
// if conditions to determine if the date field's value is an array or a string
if (typeof fieldDateValue === 'string') {
if (typeof fieldDateValue === 'string' || typeof fieldDateValue === 'number') {
keys.push(moment.utc(fieldDateValue).tz(timezone).format(dateFormat));
} else if (
dateValue.length !== 0 &&
Expand Down Expand Up @@ -311,4 +311,4 @@ const addDocValueFields = (report: any, requestBody: any) => {
docvalue_fields: docValues,
};
return requestBody;
};
};

0 comments on commit 0e39af9

Please sign in to comment.