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
API not capturing conversion_id property update #1011
Comments
I'm not sure what's causing this. Without |
Interesting. I'm not as familiar with SQLAlchemy as I'd like to be, but I know other ORMs (such as TypeORM) require that you have a separate property if you want access to just the related table's id. Ex: "conversion": ForeignKey, "conversion_id": string.. Would you consider joining the conversion table for the api? I'd imagine that users would prefer having that data included if they've converted a measurement. "device measurements": [
{
"channel": 0,
"conversion": {
"unique_id": "5b5e378a-42ac-4863-a2da-1e71897b244b",
"unit": "F"
},
...
}
], |
That would be fine, I just don't know how to dot hat. |
Not sure if it's something you're interested in implementing but I've accomplished what I described above by doing the following: In ~/Mycodo/databases/measurements.py
In ~/Mycodo/mycodo/mycodo_flask/api/sql_schema_fields.py
In ~/Mycodo/mycodo/mycodo_flask/api/input.py
to this:
|
I'm very interested. Thanks for figuring that out and sharing. I'll see about implementing it for all the foreign keys. |
What is the import for this? |
|
Hey - quick fix for this solution. Need to make the change below to ensure this is a LEFT JOIN or "device measurements" will return null if conversion_id is undefined - device_id=unique_id).join(DeviceMeasurements.conversion).all(), many=True)) + device_id=unique_id).join(DeviceMeasurements.conversion, isouter=True).all(), many=True)) I'll close this issue. Thanks for implementing. |
Thanks for figuring this out |
Describe the problem/bug
When converting an input measurement the 'conversion_id' prop of "device measurement settings" in the API stays null while the db reflects the update
Versions:
Reproducibility
Convert an input measurement via UI
GET api/settings/device_measurements/by_device_id/[unique_id]
Bug: DB has conversion_id ref but API does not
thank you
The text was updated successfully, but these errors were encountered: