Mr-Help commited on
Commit
5ccf06c
·
verified ·
1 Parent(s): 9fbcd83

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -13
app.py CHANGED
@@ -282,36 +282,44 @@ async def task_update(request: Request):
282
  if tag_name and tag_name.lower() == "missed due date":
283
 
284
  # Step 1: Prepare data
285
- # Fetch task details
286
- task_details = get_task_details(task_id) # Function to fetch task details
287
  print(f"Task details: {task_details}")
288
 
289
- # Extract assignee usernames
290
- assignee_ids = [assignee['username'] for assignee in task_details.get('assignees', [])]
291
- print(assignee_ids)
292
 
293
- # Extract space id
294
  space_id = task_details.get("space", {}).get("id")
295
-
296
- # Step 2: Prepare the request
297
  url = "https://script.google.com/macros/s/AKfycbxAF_YXKonRWoPo7MurkeC3UbUqZyNsPT85SE9AukuJAaG6mTzwtn7N-PVo4j-Qv2LP/exec"
298
  params = {
299
  "mode": "notify",
300
  "spaceId": space_id,
301
  }
302
- # Add assignee parameters one by one (e.g., assignees=123&assignees=456)
303
  for assignee_id in assignee_ids:
304
- params.setdefault("assignees", []).append(str(assignee_id))
305
 
306
  # Step 3: Make the request
307
  response = requests.get(url, params=params)
308
 
309
- # Step 4: Parse and print result
310
  if response.ok:
311
  notify_map = response.json()
312
- print("Notify Map:", notify_map)
 
 
 
 
 
 
 
313
  else:
314
- print("Failed to fetch data:", response.status_code, response.text)
 
 
315
 
316
  # Get due date
317
  due_date_timestamp = task_details.get("due_date")
 
282
  if tag_name and tag_name.lower() == "missed due date":
283
 
284
  # Step 1: Prepare data
285
+ task_details = get_task_details(task_id)
 
286
  print(f"Task details: {task_details}")
287
 
288
+ # Extract assignee **IDs**
289
+ assignee_ids = [str(assignee['id']) for assignee in task_details.get('assignees', [])]
290
+ print("Assignee IDs:", assignee_ids)
291
 
292
+ # Extract space ID
293
  space_id = task_details.get("space", {}).get("id")
294
+
295
+ # Step 2: Prepare the request to Apps Script Web App
296
  url = "https://script.google.com/macros/s/AKfycbxAF_YXKonRWoPo7MurkeC3UbUqZyNsPT85SE9AukuJAaG6mTzwtn7N-PVo4j-Qv2LP/exec"
297
  params = {
298
  "mode": "notify",
299
  "spaceId": space_id,
300
  }
301
+ # Append assignees[] multiple times for each ID
302
  for assignee_id in assignee_ids:
303
+ params.setdefault("assignees", []).append(assignee_id)
304
 
305
  # Step 3: Make the request
306
  response = requests.get(url, params=params)
307
 
308
+ # Step 4: Handle the response
309
  if response.ok:
310
  notify_map = response.json()
311
+ print("Notify Map:", notify_map)
312
+
313
+ # ✅ Extract and print all phone numbers
314
+ user_numbers = list(notify_map.get("users", {}).values())
315
+ manager_numbers = notify_map.get("managers", [])
316
+
317
+ print("📞 User Numbers:", user_numbers)
318
+ print("👨‍💼 Manager Numbers:", manager_numbers)
319
  else:
320
+ print("Failed to fetch notify data:", response.status_code)
321
+ print("Raw response:", response.text)
322
+
323
 
324
  # Get due date
325
  due_date_timestamp = task_details.get("due_date")