Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix date format in csv files #148

Merged

Conversation

kavithacm
Copy link
Collaborator

@kavithacm kavithacm commented Jul 13, 2023

Description

Date format of nested fields are modified according to advanced settingsDate format of nested fields according to advanced settings

Issues Resolved

#106

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>
Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>
@kavithacm
Copy link
Collaborator Author

kavithacm commented Sep 20, 2023

The data used to test is the following, also have attached the csv report generated using it

data._source:  {
  key1: {
    key11: 'value11',
    key12: '2023-04-26T04:34:32Z',
    key13: '2023-04-26T04:34:32Z'
  },
  key2: '2023-04-21T04:34:32Z',
  key3: 'value3',
  a: { b: { c: '2023-07-21T18:40:01Z' } }
}

fixed-csv.csv

Copy link
Contributor

@pjfitzgibbons pjfitzgibbons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output CSV is still posting all days as Jan 01.

_index,_id,_version,_score,_source.key1.key11,_source.key1.key12,_source.key1.key13,_source.key2,_source.key3,_source.a.b.c
test_index3,test,1,1,value11,01/01/2023,01/01/2023,01/01/2023,value3,01/01/2023

I am going to strongly recommend you include the recommendations in issue #196.

Since the fix of this code is this far off the mark, the refactor recommended should take less than a day, and will improve testability and readability and help in debugging the issue at hand.

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>
@kavithacm
Copy link
Collaborator Author

The output CSV is still posting all days as Jan 01.

_index,_id,_version,_score,_source.key1.key11,_source.key1.key12,_source.key1.key13,_source.key2,_source.key3,_source.a.b.c
test_index3,test,1,1,value11,01/01/2023,01/01/2023,01/01/2023,value3,01/01/2023

I am going to strongly recommend you include the recommendations in issue #196.

Since the fix of this code is this far off the mark, the refactor recommended should take less than a day, and will improve testability and readability and help in debugging the issue at hand.

I added the wrong csv file, can you check this one?
correct-csv.csv

Copy link
Member

@joshuali925 joshuali925 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you update unit tests to cover this fix?

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>
Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>
Copy link
Member

@joshuali925 joshuali925 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some questions

Comment on lines +124 to +128
{
customer_birth_date: '2023-04-26T04:34:32Z',
order_date: '2023-04-26T04:34:32Z',
'products.created_on': '2023-04-26T04:34:32Z',
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does adding this do?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the previous hit data was missing required date fields and a field object which consists of all date fields from backend. This data is required for the test to pass. Currently this fields object is being sent from backend, so while mocking the hits, we need to also include field object as well. Adding a current format for example

 {
  _index: 'test_index3',
  _id: 'test',
  _version: 1,
  _score: 1,
  _source: {
    key1: {
      key11: 'value11',
      key12: '2023-04-26T04:34:32Z',
      key13: '2023-04-26T04:34:32Z'
    },
    key2: '2023-04-21T04:34:32Z',
    key3: 'value3',
    a: { b: [Object] }
  },
  fields: {
    'key1.key12': [ '2023-04-26T04:34:32.000' ],
    'key1.key13': [ '2023-04-26T04:34:32.000' ],
    key2: [ '2023-04-21T04:34:32.000' ],
    'a.b.c': [ '2023-07-21T18:40:01.000' ]
  }
}

@@ -526,7 +1369,6 @@ test('create report with empty/one/multiple(list) date values', async () => {
undefined,
mockLogger
);

expect(dataUrl).toEqual(
'category,customer_gender,order_date\n' +
'c1,Ma,[]\n' +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the expected data didn't change with the test input change?

Copy link
Collaborator Author

@kavithacm kavithacm Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because we aren't checking all the date fields available in all tests, just the ones we need, so the expected data isn't modified but for the function to work as expected, all date value fields should be included in the hits.

Copy link
Member

@joshuali925 joshuali925 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

'products.created_on': '2023-04-26T04:34:32Z',
}
),
// }),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: can remove this comment and one line 922

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

fieldDateValue.length !== 0 &&
fieldDateValue instanceof Array
) {
console.log('entered');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: can remove the console log from here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 5, 2023
* Fix date format in csv files

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* covered all test cases

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* add index

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* fixed jest tests

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* remove commented code

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* remove commented line and console log

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

---------

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>
(cherry picked from commit 93a8704)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 5, 2023
* Fix date format in csv files

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* covered all test cases

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* add index

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* fixed jest tests

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* remove commented code

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* remove commented line and console log

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

---------

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>
(cherry picked from commit 93a8704)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
pjfitzgibbons pushed a commit that referenced this pull request Oct 5, 2023
* Fix date format in csv files

---------
(cherry picked from commit 93a8704)

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
kavithacm pushed a commit that referenced this pull request Oct 6, 2023
* Fix date format in csv files



* covered all test cases



* add index



* fixed jest tests



* remove commented code



* remove commented line and console log



---------


(cherry picked from commit 93a8704)

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 23, 2023
* Fix date format in csv files

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* covered all test cases

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* add index

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* fixed jest tests

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* remove commented code

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* remove commented line and console log

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

---------

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>
(cherry picked from commit 93a8704)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 23, 2023
* Fix date format in csv files

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* covered all test cases

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* add index

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* fixed jest tests

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* remove commented code

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* remove commented line and console log

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

---------

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>
(cherry picked from commit 93a8704)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 23, 2023
* Fix date format in csv files

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* covered all test cases

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* add index

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* fixed jest tests

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* remove commented code

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* remove commented line and console log

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

---------

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>
(cherry picked from commit 93a8704)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 23, 2023
* Fix date format in csv files

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* covered all test cases

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* add index

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* fixed jest tests

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* remove commented code

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* remove commented line and console log

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

---------

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>
(cherry picked from commit 93a8704)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 23, 2023
* Fix date format in csv files

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* covered all test cases

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* add index

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* fixed jest tests

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* remove commented code

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* remove commented line and console log

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

---------

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>
(cherry picked from commit 93a8704)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 23, 2023
* Fix date format in csv files

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* covered all test cases

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* add index

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* fixed jest tests

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* remove commented code

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* remove commented line and console log

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

---------

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>
(cherry picked from commit 93a8704)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
mengweieric pushed a commit to mengweieric/dashboards-reporting that referenced this pull request Nov 6, 2023
* Fix date format in csv files

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* covered all test cases

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* add index

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* fixed jest tests

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* remove commented code

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* remove commented line and console log

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

---------

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>
(cherry picked from commit 93a8704)
@kavithacm kavithacm mentioned this pull request Nov 6, 2023
6 tasks
pjfitzgibbons pushed a commit that referenced this pull request Nov 7, 2023
* Fix date format in csv files



* covered all test cases



* add index



* fixed jest tests



* remove commented code



* remove commented line and console log



---------


(cherry picked from commit 93a8704)

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
mengweieric added a commit that referenced this pull request Nov 7, 2023
* Fix date format in csv files (#148)

* Fix date format in csv files

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* covered all test cases

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* add index

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* fixed jest tests

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* remove commented code

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

* remove commented line and console log

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>

---------

Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>
(cherry picked from commit 93a8704)

* update snapshots to fix CIs

Signed-off-by: Eric <menwe@amazon.com>

---------

Signed-off-by: Eric <menwe@amazon.com>
Co-authored-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants