-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshift_search.py
48 lines (40 loc) · 1.47 KB
/
shift_search.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from wsse.client.requests.auth import WSSEAuth
import requests
import statistics
import os
wsse_auth = WSSEAuth(os.getenv("API_USERNAME"), os.getenv("API_SECRET"))
"""
Check for a specific shift, if people are contributing enough. Precisiely,
determine if any Lab_TA are less than 1 std below the mean number of students helped per TA
"""
def main():
start_time = "2022-02-21T19:00"
end_time = "2022-02-21T21:00"
url = "https://www.labqueue.io/api/v1/requests/query/"
payload = {"created_after": start_time,
"created_before": end_time,
}
result = requests.get(url, auth=wsse_auth, params=payload)
d: dict = result.json()
print("Total victims", d['count'])
print('-----------------')
analyze(d['results'])
def analyze(d):
lab_ta_count = {}
for victim in d:
lab_ta: str = victim['acceptor_netid']
if lab_ta != 'N/A': # not accetped by a TA, ususally closed quickly by user
lab_ta_count[lab_ta] = lab_ta_count.get(lab_ta, 0) + 1
for k, v in lab_ta_count.items():
print(k, v)
helped = lab_ta_count.values()
mu = statistics.mean(helped)
sigma = statistics.stdev(helped, mu)
print('-----------------')
print("mu =", mu)
print("sigma =", sigma)
for lab_ta in lab_ta_count:
if lab_ta_count[lab_ta] < mu - sigma:
print(lab_ta, "is not pulling their weight: %d vs mean of %f" % (lab_ta_count[lab_ta], mu))
if __name__ == '__main__':
main()