Skip to content

Commit 9612979

Browse files
Create tasks & attendance records using Python & API server using locally
1 parent ff37546 commit 9612979

File tree

4 files changed

+96
-0
lines changed

4 files changed

+96
-0
lines changed

docs/attendance-task-create.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import csv
2+
import asyncio
3+
import aiohttp
4+
import ssl
5+
6+
ssl_context = ssl.create_default_context()
7+
ssl_context.check_hostname = False
8+
ssl_context.verify_mode = ssl.CERT_NONE
9+
10+
with open('./data/attendance-task/results.csv', newline='') as csvfile:
11+
reader = csv.reader(csvfile)
12+
counter = 0
13+
total_coutner = 0
14+
memo = {}
15+
for row in reader:
16+
if total_coutner == 0:
17+
total_coutner += 1
18+
continue
19+
20+
sessionId = row[0]
21+
if sessionId == "a0pcX0000005lZNQAY":
22+
continue
23+
coach1 = row[4]
24+
coach2 = row[5]
25+
attendanceDate = row[6]
26+
memo[sessionId] = (coach1, coach2, attendanceDate)
27+
28+
total_coutner += 1
29+
30+
31+
# reader = csv.reader(csvfile)
32+
# print(f"Total coach mismatches: {counter}")
33+
# print(f"Total records: {total_coutner}")
34+
async def send_post_request(http_session, session, coach, endOfTeamSeason):
35+
url = "https://localhost:8091/api/tasks"
36+
headers = {
37+
'Content-Type': 'application/json'
38+
}
39+
payload = {
40+
"AssignedBy": "",
41+
"AssignedTo": coach,
42+
"CreatedByContact": "0051T000009eHfvQAE",
43+
"CreatedContact": "",
44+
"LastModifiedBy": "0051T000009eHfvQAE",
45+
"LastModifiedContact": "",
46+
"OwnerId": "0051T000009eHfvQAE",
47+
"DueDate": endOfTeamSeason,
48+
"Session": session,
49+
"Name": "Catch-up attendance",
50+
"TaskStatus": "To Do",
51+
"TaskType": "Take Attendance"
52+
}
53+
54+
try:
55+
async with http_session.post(url, headers=headers, json=payload, ssl=ssl_context) as response:
56+
return await response.text(), response.status
57+
except Exception as e:
58+
print(e)
59+
return None, None
60+
61+
async def main():
62+
async with aiohttp.ClientSession() as http_session:
63+
for session_id, (coach1, coach2, end_of_team_season) in memo.items():
64+
print(f"Processing session {session_id} with coaches {coach1} and {coach2} ({end_of_team_season})")
65+
if coach1 == coach2:
66+
resp = await send_post_request(http_session, session_id, coach1, end_of_team_season)
67+
print(resp)
68+
else:
69+
resp1 = await send_post_request(http_session, session_id, coach1, end_of_team_season)
70+
print(resp1)
71+
resp2 = await send_post_request(http_session, session_id, coach2, end_of_team_season)
72+
print(resp2)
73+
print(f"------------------------------------------------------------------------------------------")
74+
75+
asyncio.run(main())
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
SELECT
2+
Id,
3+
Session_Date__c,
4+
Team_Season__c,
5+
Session_Topic__c,
6+
Team_Season__r.Coach_Soccer__c,
7+
Team_Season__r.Coach_Writing__c
8+
FROM Session__c
9+
WHERE
10+
Session_Date__c >= 2025-01-01 AND
11+
Id NOT IN (
12+
SELECT Session__c
13+
FROM SCORES_Task__c
14+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"Id","Session_Date__c","Team_Season__c","Session_Topic__c","Team_Season__r.Coach_Soccer__c","Team_Season__r.Coach_Writing__c","Team_Season__r.Season_End_Date__c"
2+
"a0pcX0000005lZNQA2","2026-09-23","a0qcX000000GEggQA2","Soccer","003Hs00004W5kzXIA2","003cX000005TYcvQA2","2025-06-21"

scripts/exchange-update.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,11 @@ def increment_version(version_str):
351351
identical, details = are_files_identical("salesforce-data-api.zip", "new_salesforce-data-api.zip", ignore_list=ignore_patterns)
352352
if identical:
353353
print("Files are identical. No need to upload asset.")
354+
if change_api_specification(latest_version, token):
355+
print("API specification updated successfully.")
356+
else:
357+
print("Failed to update API specification.")
358+
exit(1)
354359
print("=======================================")
355360
print(" SUCCESS: Asset updated successfully")
356361
print("=======================================")

0 commit comments

Comments
 (0)