Repository: uclapi/uclapi

Issue:
Undocumented classification
Hi there, 
I've just noticed that there are some new(?) classifications that are not in the docs. 
These are:
* `TH`
* `CFE`
* `MR`
* `ER`
* `CF`

What do these stand for?

Thanks,
Tiago


Discussion:
Very good question
@ChristopherHammond13 any clue what these could mean? I'd be happy to make a PR for the docs if you just list the meanings here.
Hey! Apologies for not getting back to this sooner. I have done some digging and will (hopefully soon!) be sent the data dictionary for the CMIS database that this talks to. With that I'll be able to fill in all the random bits of data we don't know.

Could you give me some example bookings that are coming up with these and I'll see what I can add from guess-work?
Sure thing, here are some examples:

### TH
```json
{
      "roomname": "IOE - Bedford Way (20) - 744",
      "roomid": "744",
      "siteid": "162",
      "sitename": "IOE - Bedford Way, 20",
      "capacity": 25,
      "classification": "TH",
      "automated": "N",
      "location": {
        "address": [
          "20 Bedford Way",
          "London",
          "WC1H 0AL",
          ""
        ],
        "coordinates": {
          "lat": "51.523471",
          "lng": "-0.1285067"
        }
      }
    }
```

### CFE
```json
{
      "automated": "N",
      "location": {
        "address": [
          "9-11 Endsleigh Gardens",
          "London",
          "WC1H 0EH",
          ""
        ],
        "coordinates": {
          "lng": "-0.1314654",
          "lat": "51.526198"
        }
      },
      "capacity": 18,
      "roomid": "EGG5",
      "roomname": "IOE - Endsleigh Gardens (9-11) - G05",
      "siteid": "084",
      "sitename": "IOE - Endsleigh Gardens, 9-11",
      "classification": "CFE"
    }
```

### MR
```json
{
      "roomname": "Wilkins Garden Room",
      "roomid": "34",
      "siteid": "050",
      "sitename": "Bernard Katz Building",
      "capacity": 20,
      "classification": "MR",
      "automated": "P",
      "location": {
        "address": [
          "Gower Street,",
          "London",
          "WC1E 6BT",
          ""
        ],
        "coordinates": {
          "lat": "51.5247725",
          "lng": "-0.1334268"
        }
      }
    }
```

### ER
```json
{
      "roomname": "Wilkins Building (Main Building) North Observatory",
      "roomid": "XG1",
      "siteid": "005",
      "sitename": "Main Building",
      "capacity": 6,
      "classification": "ER",
      "automated": "N",
      "location": {
        "address": [
          "Gower Street",
          "London",
          "WC1E 6BT",
          ""
        ],
        "coordinates": {
          "lat": "51.524699",
          "lng": "-0.13366"
        }
      }
    }
```

### CF
```json
{
      "roomname": "Wilkins Building (Main Building) Whistler Room",
      "roomid": "G09D",
      "siteid": "005",
      "sitename": "Main Building",
      "capacity": 10,
      "classification": "CF",
      "automated": "N",
      "location": {
        "address": [
          "Gower Street",
          "London",
          "WC1E 6BT",
          ""
        ],
        "coordinates": {
          "lat": "51.524699",
          "lng": "-0.13366"
        }
      }
    }
```
MR - Marquee? is the only one I can get :thinking: 
MR - Marquee makes sense.
ER - Equipment room
I think all the classifications are here: https://roombooking.ucl.ac.uk/rb/bookableSpace/viewAllBookableSpace.html?invoker=EFD
Update: I'm currently updating the room bookings API to return a human-readable version of the room type (with the field `classification_str`) based on the data shown on the UCL Room Bookings site. Watch this space! :)

Resolving patch:
diff --git a/backend/uclapi/roombookings/helpers.py b/backend/uclapi/roombookings/helpers.py
--- a/backend/uclapi/roombookings/helpers.py
+++ b/backend/uclapi/roombookings/helpers.py
@@ -7,7 +7,7 @@
 import pytz
 import redis
 
-from django.core.exceptions import FieldError, ObjectDoesNotExist
+from django.core.exceptions import FieldError
 from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
 
 import ciso8601
@@ -20,6 +20,30 @@
 
 TOKEN_EXPIRY_TIME = 30 * 60
 
+ROOM_TYPE_MAP = {
+    "AN": "Anechoic Chamber",
+    "CI": "Clinic Room",
+    "CF": "Catering Facilities",
+    "CFE": "Cafe",
+    "CL": "Cloakroom",
+    "CR": "Classroom",
+    "ER": "Equipment Room",
+    "IN": "Installation",
+    "LA": "Laboratory",
+    "LB": "Library",
+    "LT": "Lecture Theatre",
+    "MR": "Meeting Room",
+    "OF": "Office",
+    "PC1": "Public Cluster",
+    "PC2": "Public Cluster - Tutorial",
+    "PC3": "Public Cluster - Students",
+    "RC": "Reverberation Chamber",
+    "SS": "Social Space",
+    "STU": "Studio",
+    "TH": "Theatre",
+}
+
+
 def _create_page_token(query, pagination):
     r = redis.StrictRedis(host=REDIS_UCLAPI_HOST)
     page_data = {
@@ -151,6 +175,12 @@ def _parse_datetime(start_time, end_time, search_date):
 def _serialize_rooms(room_set):
     rooms = []
     for room in room_set:
+        # Maps room classification to a textual version
+        # e.g. LT => Lecture Theatre
+        classification_name = ROOM_TYPE_MAP.get(
+            room.roomclass,
+            "Unknown Room Type"
+        )
         room_to_add = {
             "roomname": room.roomname,
             "roomid": room.roomid,
@@ -158,6 +188,7 @@ def _serialize_rooms(room_set):
             "sitename": room.sitename,
             "capacity": room.capacity,
             "classification": room.roomclass,
+            "classification_name": classification_name,
             "automated": room.automated,
             "location": {
                 "address": [
@@ -308,8 +339,8 @@ def _filter_for_free_rooms(all_rooms, bookings, start, end):
     for room in rooms_with_bookings:
         roomid, siteid = room["roomid"], room["siteid"]
         if (
-            (roomid, siteid) not in bookings_map
-            or not bookings_map[(roomid, siteid)]
+            (roomid, siteid) not in bookings_map or
+            not bookings_map[(roomid, siteid)]
         ):
             # if room doesn't have any overlapping bookings
             free_rooms.append(room)


Test patch: