ideafast / middleware-services

Python API containing endpoints for smartphone hub applications and transfer to data portal
0 stars 0 forks source link

Ensure + validate inventory `record_by_device_id` returns correct result #53

Closed davidverweij closed 3 years ago

davidverweij commented 3 years ago

In testing the BTF pipeline, I found the inventory service did not return the appropriate result. Potentially this has to do with the inventory not having an end wear when the device is still being deployed. We should set up some tests to validate this method's functionality, and figure out why it doesn't pick up the query correctly.

Test case

record_by_device_id(
    "BTF-CS4P34",
    start=datetime.datetime(2021, 3, 26, 8, 30, 18, 370009), 
    end=datetime.datetime(2021, 3, 26, 8, 30, 21, 565704))
)

Returns: None

Logs do confirm that when checkin is null, the method does replace it with the current time.

Manually querying the inventory returns:

{
    "data": {
        "K-ABCABC": {
            "patient_id": "K-ABCABC",
            "device_id": "BTF-CS4P34",
            "checkout": "2021-03-18 19:38:49",
            "checkin": null
        },
       "etc" :{
        }
    },
    "meta": {
        "success": true,
        "errors": null
    }
}

Which indicates that is should have returned K-ABCABC. (anonymised)

jawrainey commented 3 years ago

For reference, this is likely becase normalise_day only nulls hours and minutes, and not miliseconds. For example:

>>> now
datetime.datetime(2021, 3, 26, 0, 0, 0, 647241)
>>> endr 
datetime.datetime(2021, 3, 26, 0, 0, 0, 565704)
>>> now <= endr
False
jawrainey commented 3 years ago

This was resolved in #56