Skip to content

Commit

Permalink
Make changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-Jess committed Nov 17, 2024
1 parent 0663073 commit 93987c2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 24 deletions.
34 changes: 13 additions & 21 deletions backend/laundry/api_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,18 @@ def parse_a_room(room_request_link):
request_json = get_validated(room_request_link)
if request_json is None:
return {"washers": washers, "dryers": dryers, "details": detailed}

[
update_machine_object(machine, washers) if machine["isWasher"] else None
for machine in request_json
]
[
update_machine_object(machine, dryers) if machine["isDryer"] else None
for machine in request_json
]
[
detailed.append(
{
"id": machine["id"],
"type": "washer" if machine["isWasher"] else "dryer",
"status": machine["currentStatus"]["statusId"],
"time_remaining": machine["currentStatus"]["remainingSeconds"],
}
)
for machine in request_json:
if machine["isWasher"]:
update_machine_object(machine, washers)
elif machine["isDryer"]:
update_machine_object(machine, dryers)
detailed = [
{
"id": machine["id"],
"type": "washer" if machine["isWasher"] else "dryer",
"status": machine["currentStatus"]["statusId"],
"time_remaining": machine["currentStatus"]["remainingSeconds"],
}
for machine in request_json
if machine["isWasher"] or machine["isDryer"]
]
Expand All @@ -102,9 +96,7 @@ def check_is_working():
"""

all_rooms_request = get_validated(f"{settings.LAUNDRY_URL}/geoBoundaries/5610?raw=true")
if all_rooms_request is None:
return False
return True
return all_rooms_request is not None

Check warning on line 99 in backend/laundry/api_wrapper.py

View check run for this annotation

Codecov / codecov/patch

backend/laundry/api_wrapper.py#L98-L99

Added lines #L98 - L99 were not covered by tests


def all_status():
Expand Down
7 changes: 5 additions & 2 deletions backend/penndata/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from rest_framework.response import Response
from rest_framework.views import APIView

from laundry.models import LaundryRoom
from penndata.models import (
AnalyticsEvent,
CalendarEvent,
Expand Down Expand Up @@ -175,12 +176,14 @@ def get(self, request):
cells = []

# adds laundry preference to home, defaults to 0 if no preference
# TODO: This defaults to a nonexistent room, not sure if that's problematic
# TODO: This defaults to the first room, change potentially
laundry_preference = profile.laundry_preferences.first()
if laundry_preference:
cells.append(self.Cell("laundry", {"room_id": laundry_preference.room_id}, 5))
else:
cells.append(self.Cell("laundry", {"room_id": 0}, 5))
cells.append(
self.Cell("laundry", {"room_id": list(LaundryRoom.objects.all())[0].room_id}, 5)
)

# adds dining preference to home with high priority, defaults to 1920's, Hill, NCH
dining_preferences = [
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/penndata/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def test_first_response(self):
self.assertIn(636, dining_info)

self.assertEqual(res_json[2]["type"], "laundry")
self.assertEqual(res_json[2]["info"]["room_id"], 0)
self.assertIn(res_json[2]["info"]["room_id"], [14089, 14099, 14100])

self.test_user.profile.dining_preferences.add(Venue.objects.get(venue_id=747))
self.test_user.profile.dining_preferences.add(Venue.objects.get(venue_id=1733))
Expand Down

0 comments on commit 93987c2

Please sign in to comment.