fablabbcn / smartcitizen-api

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

Communities and experiments #259

Open oscgonfer opened 9 months ago

oscgonfer commented 9 months ago

As mentioned, this idea has been there for a while, but this issue is to discuss potential integrations of a new concept in the data model for users: communities, and their relationships with devices: experiments

Communities: simply a group of users with a description and a name:

{
  "id": 123,
   "name": "Community of Santa Coloma",
   "description": "A group studying the impact of the new park in Santa Coloma in terms of PM2.5",
   "users":  [list of users],
   "experiments": [list of experiments],
   "tags": ??
  ...
  ???
}

Experiments: relationship between devices containing a set of readings and potential other links and metadata:

{
  "id": 1234,
  "name": "PM2.5 Summer test",
  "description": "...",
  "status": "active"
  "devices":
     [
       {"device_id": 12345,
        "from": "2023-09-12T00:00:00",
        "to": "now"},
      ...
     ]
}

Just adding some thoughts here. Maybe this can be discussed further for next year.

oscgonfer commented 6 days ago

Updates on experiments model:

{
  "id": 1234,
  "name": "PM2.5 Summer test",
  "description": "...",
  "status": "active",
  "is_test": false,
  "start_date": "2024-05-03T21:00:01Z",
  "end_date": null,
  "devices":
     [
       12345,
       12346,
       12347
     ]
}

@timcowlishaw what do you think? I added the _istest flag.

timcowlishaw commented 4 days ago

What values do we want for the "status" field @oscgonfer ?

oscgonfer commented 4 days ago

Good question, I hadn't put much thought on it.

An experiment can be basically on-going or not (duh). Reasons for not on-going could be various: stalled, finalized... However, for the shake of simplicity I was thinking something along the lines of active, completed.

So, if we only have two options, then rather make it a boolean, and change status for active, and keep it simple. Later on, we can think of a different business logic if needed. What do you think?

timcowlishaw commented 2 days ago

ok, changed "status" to an "active" boolean - the experiments part of this is in #343, but leaving the ticket open 'til we've tackled communities.