benjolo commited on
Commit
9e2e884
·
verified ·
1 Parent(s): f75d5c2

adding mongo db functionality to calls

Browse files

Uncommented mongo operation code in main.py

Files changed (1) hide show
  1. backend/main.py +23 -23
backend/main.py CHANGED
@@ -234,19 +234,19 @@ async def call_user(sid, call_id):
234
  gunicorn_logger.info(f"CALL {sid}: room {call_id} is full")
235
  # await sio.emit("room_full", room=call_id, to=sid)
236
 
237
- # # BO - Get call id from dictionary created during socketio connection
238
- # client_id = clients[sid].client_id
239
 
240
- # gunicorn_logger.warning(f"NOW TRYING TO CREATE DB RECORD FOR Caller with ID: {client_id} for call: {call_id}")
241
- # # # BO -> Create Call Record with Caller and call_id field (None for callee, duration, terms..)
242
- # request_data = {
243
- # "call_id": str(call_id),
244
- # "caller_id": str(client_id),
245
- # "creation_date": str(datetime.now())
246
- # }
247
 
248
- # response = create_calls(get_collection_calls(), request_data)
249
- # print(response) # BO - print created db call record
250
 
251
  @sio.on("audio_config")
252
  async def audio_config(sid, sample_rate):
@@ -267,18 +267,18 @@ async def answer_call(sid, call_id):
267
  # await sio.emit("room_full", room=call_id, to=sid)
268
 
269
 
270
- # # BO - Get call id from dictionary created during socketio connection
271
- # client_id = clients[sid].client_id
272
 
273
- # # BO -> Update Call Record with Callee field based on call_id
274
- # gunicorn_logger.warning(f"NOW UPDATING MongoDB RECORD FOR Caller with ID: {client_id} for call: {call_id}")
275
- # # # BO -> Create Call Record with callee_id field (None for callee, duration, terms..)
276
- # request_data = {
277
- # "callee_id": client_id
278
- # }
279
-
280
- # response = update_calls(get_collection_calls(), call_id, request_data)
281
- # print(response) # BO - print created db call record
282
 
283
 
284
  @sio.on("incoming_audio")
@@ -310,7 +310,7 @@ async def incoming_audio(sid, data, call_id):
310
  print(f"TRANSLATED TEXT = {translated_text}")
311
 
312
  # BO -> send translated_text to mongodb as caption record update based on call_id
313
- # send_captions(clients[sid].client_id, asr_text, translated_text, call_id)
314
 
315
  # TRANSLATED TEXT
316
  # PM - text_output is a list with 1 string
 
234
  gunicorn_logger.info(f"CALL {sid}: room {call_id} is full")
235
  # await sio.emit("room_full", room=call_id, to=sid)
236
 
237
+ # BO - Get call id from dictionary created during socketio connection
238
+ client_id = clients[sid].client_id
239
 
240
+ gunicorn_logger.warning(f"NOW TRYING TO CREATE DB RECORD FOR Caller with ID: {client_id} for call: {call_id}")
241
+ # # BO -> Create Call Record with Caller and call_id field (None for callee, duration, terms..)
242
+ request_data = {
243
+ "call_id": str(call_id),
244
+ "caller_id": str(client_id),
245
+ "creation_date": str(datetime.now())
246
+ }
247
 
248
+ response = create_calls(get_collection_calls(), request_data)
249
+ print(response) # BO - print created db call record
250
 
251
  @sio.on("audio_config")
252
  async def audio_config(sid, sample_rate):
 
267
  # await sio.emit("room_full", room=call_id, to=sid)
268
 
269
 
270
+ # BO - Get call id from dictionary created during socketio connection
271
+ client_id = clients[sid].client_id
272
 
273
+ # BO -> Update Call Record with Callee field based on call_id
274
+ gunicorn_logger.warning(f"NOW UPDATING MongoDB RECORD FOR Caller with ID: {client_id} for call: {call_id}")
275
+ # # BO -> Create Call Record with callee_id field (None for callee, duration, terms..)
276
+ request_data = {
277
+ "callee_id": client_id
278
+ }
279
+
280
+ response = update_calls(get_collection_calls(), call_id, request_data)
281
+ print(response) # BO - print created db call record
282
 
283
 
284
  @sio.on("incoming_audio")
 
310
  print(f"TRANSLATED TEXT = {translated_text}")
311
 
312
  # BO -> send translated_text to mongodb as caption record update based on call_id
313
+ send_captions(clients[sid].client_id, asr_text, translated_text, call_id)
314
 
315
  # TRANSLATED TEXT
316
  # PM - text_output is a list with 1 string