quality-time icon indicating copy to clipboard operation
quality-time copied to clipboard

Use pydantic to generate json, instead of putting string attributes in entities

Open wkoot opened this issue 1 year ago • 0 comments

User story

As a developer I want to use native types as much as possible, so that I don't need to do unnecessary string munging. This includes comparing parse_datetime(entity.created_date) with something like "lookback period" or "days ago", but also the strings of SourceMeasurement total and value. Pydantic should handle conversion to json, with stringy values if needed. Note that we currently already do some comprehension; i.e. when there's a datetime string returned in an entity, but EntryAttribute type is DATE. To discuss: convert to string in collector (which means the db doesn't change), or in api (so native types can be used in all python code)?

Tasks

Components

Shared code

  • [ ] Review the data model for entities

API-server

  • [ ] TBD - should the json be generated here, or by the collector (before storing in db)?

Collector

  • [ ] Change collector so that all entity attributes are native in code instead of casting to string

wkoot avatar Dec 15 '23 12:12 wkoot