m8chaa commited on
Commit
21ff58d
·
verified ·
1 Parent(s): 0d70c72

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -248,7 +248,20 @@ async def mobile_process_receipts(background_tasks: BackgroundTasks, request: Re
248
  logging.error(f"Unexpected response from Google Apps Script API: {response.status_code} - {response.text}")
249
  raise HTTPException(status_code=500, detail="Error from external API.")
250
 
251
- background_tasks.add_task(background_worker, sheeturl, image_contents, uuid, content_type, appsScriptsURL, user_ref)
 
 
 
 
 
 
 
 
 
 
 
 
 
252
 
253
  return {"message": "Image processing completed."}
254
 
 
248
  logging.error(f"Unexpected response from Google Apps Script API: {response.status_code} - {response.text}")
249
  raise HTTPException(status_code=500, detail="Error from external API.")
250
 
251
+ # before continuing on, search db for user via sheetID
252
+ sheetID = sheeturl.split('/')[-2]
253
+ # Query the database for documents where 'sheetID' field is equal to sheetID
254
+ query_ref = users_ref.where('sheetID', '==', sheetID)
255
+ # Get the documents that match the query
256
+ user_docs = query_ref.stream()
257
+
258
+ # user_docs is an iterator of DocumentSnapshot
259
+ # You can convert it to a list if you want to work with it directly
260
+ user_docs = list(user_docs)
261
+
262
+ user_ref = user_docs[0].id
263
+
264
+ background_tasks.add_task(background_worker, sheeturl, image_contents, uuid, content_type, appsScriptsURL,user_ref)
265
 
266
  return {"message": "Image processing completed."}
267