IzzyBeraja / Flags

0 stars 0 forks source link

Add new route for getting switch states #55

Open IzzyBeraja opened 1 year ago

IzzyBeraja commented 1 year ago

Currently I have a route that gets all the switches by owner, but I'd like to add a way to get a minified version of the switches. What I mean by this is only including the name and state of the switch in a response:

{
  "switch1": true,
  "switch2": false,
  "switch3": false,
  "switch4": true
}

This should make checking which switches are passing and failing easier. Since there is a uniqueness constraint on (name, owned_by) then there won't be any overlapping objects. Implementing them as an object instead of an array will also make it easier for the frontend to check specific keys.

IzzyBeraja commented 1 year ago

As I stated in another issue, currently uniqueness between the names of flags (switches) and flows is non-existent. Although all the names for switches are currently unique relative to themselves and the owner of those switches (two different people can have the same switch name), there is no guarantees that when I add flows that those names will be unique.

I would like clients to be able to query for all the states in one shot:

{
  "switch1": true,
  "switch2": false,
  "flow1": true,
  "flow2": false,
  "nux1": "start"
}

From the perspective of the client, there isn't a difference between a flow and a switch, so using a naming convention isn't useful. Instead, I'd like to simply ensure that the names are unique between flags, flows, and other things.

This means that in order to accomplish this task, I will first need to add a new table to support the naming. Supporting this feature before that will simply force me to refactor it in the next update.