Skip to content

Commit 0f8aabe

Browse files
Merge pull request #365 from AmericaSCORESBayArea/sandbox
Enhancements: Add 'X-Firebase-UID' Header, New Endpoints for Coach Team Seasons Stats, Date Filter for Sessions, and Task Creation Script
2 parents 507e4a2 + 262735d commit 0f8aabe

File tree

12 files changed

+578
-90
lines changed

12 files changed

+578
-90
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ src/main/resources/deploy.json
5656
src/main/resources/keystore.jks
5757
/bin/
5858
/venv
59+
/docs/data

docs/Scores - Salesforce Data API.postman_collection.json

Lines changed: 63 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,6 +2008,41 @@
20082008
}
20092009
},
20102010
"response": []
2011+
},
2012+
{
2013+
"name": "/coach/{coachId}/teamseasons/{teamSeasonId}/stats",
2014+
"request": {
2015+
"method": "GET",
2016+
"header": [
2017+
{
2018+
"key": "client_id",
2019+
"value": "{{sandbox_client_id}}"
2020+
},
2021+
{
2022+
"key": "client_secret",
2023+
"value": "{{sandbox_client_secret}}"
2024+
},
2025+
{
2026+
"key": "Origin",
2027+
"value": "Postman",
2028+
"type": "text"
2029+
}
2030+
],
2031+
"url": {
2032+
"raw": "{{base_url_s}}/coach/a0qcX000000GEggQAG/003cX000008IZnXQAW/stats",
2033+
"host": [
2034+
"{{base_url_s}}"
2035+
],
2036+
"path": [
2037+
"coach",
2038+
"a0qcX000000GEggQAG",
2039+
"003cX000008IZnXQAW",
2040+
"stats"
2041+
]
2042+
},
2043+
"description": "Response Example:\n\n{ \"Not Started\": 1, \"Started\": 0, \"Complete\": 41}"
2044+
},
2045+
"response": []
20112046
}
20122047
]
20132048
},
@@ -2241,40 +2276,6 @@
22412276
},
22422277
"response": []
22432278
},
2244-
{
2245-
"name": "/tasks/{coachId}/stats",
2246-
"request": {
2247-
"method": "GET",
2248-
"header": [
2249-
{
2250-
"key": "client_id",
2251-
"value": "{{sandbox_client_id}}"
2252-
},
2253-
{
2254-
"key": "client_secret",
2255-
"value": "{{sandbox_client_secret}}"
2256-
},
2257-
{
2258-
"key": "Origin",
2259-
"value": "Postman",
2260-
"type": "text"
2261-
}
2262-
],
2263-
"url": {
2264-
"raw": "{{base_url_s}}/tasks/003cX000008IZnXQAW/stats",
2265-
"host": [
2266-
"{{base_url_s}}"
2267-
],
2268-
"path": [
2269-
"tasks",
2270-
"003cX000008IZnXQAW",
2271-
"stats"
2272-
]
2273-
},
2274-
"description": "Response Example:\n\n{ \"Not Started\": 1, \"Started\": 0, \"Complete\": 41}"
2275-
},
2276-
"response": []
2277-
},
22782279
{
22792280
"name": "/tasks/{taskId}",
22802281
"request": {
@@ -2438,6 +2439,34 @@
24382439
"response": []
24392440
}
24402441
]
2442+
},
2443+
{
2444+
"name": "Execute Custom Script",
2445+
"request": {
2446+
"method": "POST",
2447+
"header": [
2448+
{
2449+
"key": "Content-Type",
2450+
"value": "application/json"
2451+
}
2452+
],
2453+
"body": {
2454+
"mode": "raw",
2455+
"raw": "{\n \"scriptName\": \"example-script\",\n \"parameters\": {\n \"param1\": \"value1\",\n \"param2\": \"value2\"\n }\n}"
2456+
},
2457+
"url": {
2458+
"raw": "{{base_url}}/scripts/custom",
2459+
"host": [
2460+
"{{base_url}}"
2461+
],
2462+
"path": [
2463+
"scripts",
2464+
"custom"
2465+
]
2466+
},
2467+
"description": "Execute a custom script with parameters"
2468+
},
2469+
"response": []
24412470
}
24422471
],
24432472
"event": [

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"

docs/sessions-no-results.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import csv
2+
3+
memo_true = set()
4+
with open('./data/sessions-from-attendances/true.csv', newline='') as csvfile:
5+
reader = csv.reader(csvfile)
6+
for row in reader:
7+
memo_true.add(row[0])
8+
9+
10+
memo_false = set()
11+
with open('./data/sessions-from-attendances/false.csv', newline='') as csvfile:
12+
reader = csv.reader(csvfile)
13+
for row in reader:
14+
memo_false.add(row[0])
15+
16+
print(len(memo_false))
17+
print(len(memo_true))
18+
result = []
19+
for item in memo_false:
20+
if item in memo_true:
21+
continue
22+
else:
23+
result.append(item)
24+
25+
print(len(result))
26+
print(result)

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)