Update app.py
Browse files
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 |
-
|
| 286 |
-
task_details = get_task_details(task_id) # Function to fetch task details
|
| 287 |
print(f"Task details: {task_details}")
|
| 288 |
|
| 289 |
-
# Extract assignee
|
| 290 |
-
assignee_ids = [assignee['
|
| 291 |
-
print(assignee_ids)
|
| 292 |
|
| 293 |
-
# Extract space
|
| 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 |
-
#
|
| 303 |
for assignee_id in assignee_ids:
|
| 304 |
-
params.setdefault("assignees", []).append(
|
| 305 |
|
| 306 |
# Step 3: Make the request
|
| 307 |
response = requests.get(url, params=params)
|
| 308 |
|
| 309 |
-
# Step 4:
|
| 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
|
|
|
|
|
|
|
| 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")
|