Closed proffalken closed 8 months ago
Thinking about it, if the JSON that was accepted by the API was something like:
{
"sensors" : {
"beverage_supply" : [
{
"name" : "Club Mate",
"unit" : "btl",
"value" : 12
}
],
"humidity" : 55,
"temperature" : 23.2
},
"state" : "<open|closed>"
}
and then store the sensors
array in a field in the database that can be retrieved and inserted as a single JSON object, that could be a good way to fill out the full spec?
The view to show the space data would then effectively be (pseudo-code):
def space_data():
// All the fixed JSON data from constance
space_json = getConstanceData()
// get space status from database
space_status = ORM.lookup.field("space_status")
// Get the sensor data
sensor_data = ORM.lookup.field("external_sensor_data")
// Get the people information
total_members = ORM.lookup.field("members").count()
in_the_space = ORM.lookup.field("members").where("swiped_in_to_space" == True).count()
sensor_data['total_member_count'] = total_members
sensor_data['people_now_present'] = in_the_space
space_json['sensors'] = sensor_data
return jsondump(space_json)
Would be a good chance to update it to v14 of the spec too :) https://github.com/SpaceApi/schema/pull/69/commits/0b80e73eadadccd90fd4cb661d0577188840997b
@andrewbolster How did we do it at @farsetlabs when managing the open/closed status?
Would be a good chance to update it to v14 of the spec too :) SpaceApi/schema@0b80e73
Can we be "smart" about that and generate the view from the schema?
Would be a good chance to update it to v14 of the spec too :) SpaceApi/schema@0b80e73
Can we be "smart" about that and generate the view from the schema?
Sorry I'm pretty slack at replying to issues sometimes :') I meant to say I think that would be cool, but probably overkill. If you want to implement it though go for it!
Is your feature request related to a problem? Please describe. As discussed in Discord, it would be great to be able to "dynamically" update the status of whether the space is open or closed so we can take advantage of https://mapall.space/ and other widgets.
At the moment, you need to go into the Constance settings and flip the checkbox every time.
It would also be really cool to add more more data such as a message, total member count, and even people now present populated by the existing membership information/people who have swiped in etc.
Describe the solution you'd like
An API endpoint (with authentication of some sort!) that sets the status of the space to open/closed, along with dynamic fields in the JSON output that pull data from the database around total members/current people in the space etc.
Describe alternatives you've considered
Manually logging in and updating the space status.
Additional context
Full SpaceAPI schema at https://spaceapi.io/docs/, but we probably don't need to implement the entire thing (nor should we at the moment!)