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

Allow relative days for date and timestamp columns in csv-to-docs command #230

Closed
binokaryg opened this issue Sep 10, 2019 · 8 comments
Closed
Assignees
Labels
Type: Improvement Make something better

Comments

@binokaryg
Copy link
Member

We want to create a set of dummy data for web-app which includes a bunch of reports that should trigger tasks and show targets as soon as we upload them. For this to work, we need a mechanism to calculate the timestamp/date fields in the forms relative to the current date.
Although this has been done in the past by writing relative days in JSON and running through external scripts, there does not seem to be a reliable way of doing it from within medic-conf.
Can we add this feature in medic-conf?

@tookam
Copy link
Contributor

tookam commented Nov 6, 2019

ready for AT 230-csv-to-docs-with-relative-dates

@binokaryg
Copy link
Member Author

When using date_of_birth:rel-date, I get the calculated birth date as 2019-11-08T19:00:41.486Z. Is there a way to get just the date (without time) )in the ISO 8601 format: 2019-11-08?
For the rel-timestamp it could be more useful to be able to supply the time in milliseconds.

@ngaruko
Copy link
Contributor

ngaruko commented Nov 19, 2019

@wtekeu ^

@tookam
Copy link
Contributor

tookam commented Nov 20, 2019

@binokaryg the branch has been updated with your suggestions.

@binokaryg
Copy link
Member Author

Thanks, @wtekeu, rel-date works great now.
One small consideration for relative timestamps is that, is it possible to make the "current time" fixed for a single batch?
I tried creating 30 persons all with reported_date:rel-timestamp = 100.
In the resulting docs, I got three different but consecutive dates:

  1. 1574244658662 (Persons 1-6)
  2. 1574244658663 (Persons 7-22)
  3. 1574244658664 (Persons 23-30)

I guess the reason for this could be "current time" being read dynamically during the processing of each document. If that's the case, can we just read a "current time" at the beginning and stick to that throughout the batch?

Although it shouldn't create any problem in real life but it can affect automated tests.

@ngaruko
Copy link
Contributor

ngaruko commented Nov 21, 2019

Thanks @wtekeu and @binokaryg . We can approach these two ways since it is not likely to affect anyone in 'production' : a) work on it now and get it over and done if it is a minor job or b)if it is time-consuming, close the ticket and open a new one when/if it becomes an issue with automated tests.
Since the branch is PR is still active, I would go with option a) but if option b) looks more efficient, feel free to push it back to AT @wtekeu and we will decide whether there is a need for another ticket...

@tookam
Copy link
Contributor

tookam commented Nov 21, 2019

@binokaryg and @ngaruko I opted for a) .. please test latest changes

@binokaryg
Copy link
Member Author

It works like a charm! Thanks.

@binokaryg binokaryg removed their assignment Nov 22, 2019
@garethbowen garethbowen changed the title csv-to-docs: allow relative days for date and timestamp columns Allow relative days for date and timestamp columns in csv-to-docs command Nov 24, 2019
@ngaruko ngaruko closed this as completed Nov 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Improvement Make something better
Projects
None yet
Development

No branches or pull requests

4 participants