fablabbcn / smartcitizen-api

The Smart Citizen Engine
https://developer.smartcitizen.me
GNU Affero General Public License v3.0
10 stars 4 forks source link

Add device version and hardware version to `devices` #292

Closed oscgonfer closed 4 months ago

oscgonfer commented 6 months ago

Currently we use the kit representation for filling up several fields in the front-end (both in popups, tooltips, cards...). These are:

kit:
  id: 26
  slug: "sck:2,1"
  description: "Smart Citizen Kit 2.1"
  name: "SCK 2.1"

Since we are removing the /kits endpoint, we need to now populate these fields with data coming from the device/<id> or the device/world_map. I suggest some changes to the device representation as below:

Serialised JSON for API:

device
    name: OSCAR Sensor
    description: A sensor I have in my living room for whatever
    hardware:
        slug: "sck:2,1" (auto-generated based on hardware_type and hardware_version)
        type: SCK (autogenerated by the existence of hardware info or migrated)
        version: 2.1 (autogenerated by hardware info or migrated)
        description: Smart Citizen Kit 2.1(migrated and the we have basic logic to generate based on the rest)

In the device model:

device
    name: OSCAR Sensor
    description: A sensor I have in my living room for whatever
    hardware_slug: "sck:2,1" (auto-generated based on hardware_type and hardware_version)
    hardware_type: SCK (autogenerated by the existence of hardware info or migrated)
    hardware_version: 2.1 (autogenerated by hardware info or migrated)
    hardware_description: Smart Citizen Kit 2.1(migrated and the we have basic logic to generate based on the rest)

For each field:

Why? We have no way of guaranteeing that a certain version of a device has a valid hardware_info field except for very recent versions of the device.

Process

In general, we need to make sure that for, that the hardware_version field is easily parseable in the FE so that we can enable or disable features, and that there is a clear distinction between (what we call) legacy devices and non-legacy devices (i.e. kit_id <4). I suggest using the naming above with ., and making sure that both migrated and new devices are clearly defined.

I suggest a strategy for each:

For migrated devices:

For new devices:

TO-DO

oscgonfer commented 4 months ago

Let's kill hardware.description @timcowlishaw

oscgonfer commented 4 months ago

Done in https://github.com/fablabbcn/smartcitizen-api/pull/246