Boavizta / boaviztapi

🛠 Giving access to BOAVIZTA reference data and methodologies trough a RESTful API
GNU Affero General Public License v3.0
68 stars 23 forks source link

Usage component not treated in verbose #49

Closed da-ekchajzer closed 2 years ago

da-ekchajzer commented 2 years ago

Bug description

Usage components are not treated in the verbose service.

To Reproduce

Any request on a device with verbose = true won't return any information on usage components.

Expected behavior

The verbose service should treat usage component like any other components.

/!\ Usage components has attribute of dict type, a recursive function must be applied to handle embedded attributes.

da-ekchajzer commented 2 years ago

I have made an implementation in a general case. Any dict attribute of any type of component will be treated recursively.

Example for Workload

Input :

  "workload": {
    "10": {
      "time": 0.1
    },
    "50": {
      "time": 0.1
    },
    "100": {
      "time": 0.7
    },
    "idle": {
      "time": 0.1
    }
  }

Completed Input :

  "workload": {
    "10": {
      "time": 0.1,
      "power" :0.6
    },
    "50": {
      "time": 0.1,
      "power": 0.7235
    },
    "100": {
      "time": 0.7,
      "power": 1
    },
    "idle": {
      "time": 0.1,
      "power": 0.02
    }
  }

Verbose :

"workload": {
        "10": {
          "time": {
            "input_value": 0.1,
            "used_value": 0.1,
            "status": "UNCHANGED"
          },
          "power": {
            "input_value": null,
            "used_value": 0.6,
            "status": "SET"
          }
        },
        "50": {
          "time": {
            "input_value": 0.1,
            "used_value": 0.1,
            "status": "UNCHANGED"
          },
          "power": {
            "input_value": null,
            "used_value": 0.7235,
            "status": "SET"
          }
        },
        "100": {
          "time": {
            "input_value": 0.7,
            "used_value": 0.7,
            "status": "UNCHANGED"
          },
          "power": {
            "input_value": null,
            "used_value": 1,
            "status": "SET"
          }
        },
        "idle": {
          "time": {
            "input_value": 0.1,
            "used_value": 0.1,
            "status": "UNCHANGED"
          },
          "power": {
            "input_value": null,
            "used_value": 0.02,
            "status": "SET"
          }
        }
      }