-
-
Notifications
You must be signed in to change notification settings - Fork 221
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
Extract DateTime logic #35527
Extract DateTime logic #35527
Conversation
🔍 Existing Issues For ReviewYour pull request is modifying functions with the following pre-existing issues: 📄 File: corehq/apps/reports/util.py
Did you find this useful? React with a 👍 or 👎 |
Can you show where is |
I haven't traced through this, but my understanding is that somewhere along either the Pillow or Couch process, Document models are converted to JSON using the field definitions from jsonobject. Jsonobject serializes and deserializes via its |
@mjriley Without confirming we did |
One question ( no need to address it in your PR ): |
@esoergel was kind enough to point me to the code (mostly) responsible for this. The code that inserts it into ElasticSearch is here. which you can see from the method's docstring:
The parent class has that At that point, the details of how Edit: copying his notes on how the internals of JSONobject work:
|
Provided these calls represented data that was serialized by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thank you for the explanation I also learned something new from it.
Product Description
Purely a backend change.
Technical Summary
The recent CommCare Version Tile made me aware that we're inconsistent in how we're treating deserialization. The full logic is in
DateTimeProperty._wrap()
, but because it is an instance method, we ended up doing our own manual deserialization withdatetime.strptime(date_of_use, ISO_DATETIME_FORMAT)
. Although this works, it ignores the additional checks thatDateTimeProperty
does. Since, in both cases, we're handling data from the same source (data that was serialized byDateTimeProperty
), I've added a class method to allow us to re-use the same logic.Safety Assurance
Safety story
I haven't done any testing beyond the unit tests, but I believe those tests are sufficient to prove that the existing behavior has been preserved.
Automated test coverage
Added new tests to verify that the existing behavior has not been disrupted while adding the
deserialize
method.QA Plan
No QA
Rollback instructions
Labels & Review