Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy.li committed Oct 16, 2022
2 parents 815bc3e + 462f3a0 commit 11d621b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
Binary file modified backend/__pycache__/database.cpython-310.pyc
Binary file not shown.
Binary file modified backend/__pycache__/model.cpython-310.pyc
Binary file not shown.
Binary file modified backend/__pycache__/twilio_routes.cpython-310.pyc
Binary file not shown.
Binary file modified backend/__pycache__/users.cpython-310.pyc
Binary file not shown.
16 changes: 9 additions & 7 deletions backend/twilio_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@

manager = Manager()
queue = manager.dict() # phonenum : bool[]
waitTime = 10
waitTime = 30

# post body: {"username": USERNAME, "friends" : ["username1", ...]}
@twilio_bp.route('/activateAlarm/', methods=['POST'])
def explode():
data = request.json
print(data['username'])
print("------")
session = Session()
data['friends'] = session.query(User.oncall).filter_by(username=data['username']).first()
data['friends'] = data['friends'][0]
Expand Down Expand Up @@ -69,7 +71,7 @@ def childProcess(data, queue, manager):
print("----")
if queue[phoneNum].pop(0):
break
if len(queue[phoneNum]) == 0:
if phoneNum in queue and len(queue[phoneNum]) == 0:
del queue[phoneNum]
session.close()

Expand Down Expand Up @@ -97,13 +99,13 @@ def logResponse():
if 'yes' in body.lower() and phoneNum in queue:
count = 0
while count < len(queue[phoneNum]) and not queue[phoneNum][count]:
print("ok")
print(queue[phoneNum][count])
#print("ok")
#print(queue[phoneNum][count])
queue[phoneNum][count] = True
count +=1
resp.message("Thank you!")
print(queue)
print("^^^^^^^^^")
elif 'no' in body.lower():
#print(queue)
#print("^^^^^^^^^")
elif 'no' in body.lower() and phoneNum in queue:
resp.message("Aww, we'll try the next friend")
return str(resp)
8 changes: 6 additions & 2 deletions frontend/src/components/FriendSearch/FriendSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function FriendSearch() {
<div className="title">find friends</div>
<div className="search">
<TextField
style={{ width: "30vw", textAlignLast: 'center' }}
style={{ width: "20vw", textAlignLast: 'center' }}
id="outlined-basic"
variant="outlined"
fullWidth
Expand All @@ -106,6 +106,8 @@ function FriendSearch() {
onChange={inputHandler}
/>
{response && <><small style={{ color: 'red' }}>{response}</small><br /></>}<br />

<div>
<Button
style={{ backgroundColor: "rgba(186,209,250)", fontFamily: "DM SANS", textTransform: "lowercase", color: "black", boxShadow: "none", marginRight: "10px", marginBottom: "5px"}}
onClick={handleSubmit}
Expand All @@ -114,12 +116,14 @@ function FriendSearch() {
add friend
</Button>
<Button
style={{ backgroundColor: "rgba(186,209,250)", fontFamily: "DM SANS", textTransform: "lowercase", color: "black", boxShadow: "none", marginRight: "10px", marginBottom: "5px"}}
style={{ backgroundColor: "rgba(255, 242, 134, .7)", fontFamily: "DM SANS", textTransform: "lowercase", color: "black", boxShadow: "none", marginRight: "10px", marginBottom: "5px"}}
onClick={navigateAlarm}
variant="contained"
>
go back
</Button>
</div>

</div>
<p class="title"> current friends</p>
<List style={{ textAlignLast: "center" }}>
Expand Down

0 comments on commit 11d621b

Please sign in to comment.