Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions template-xapi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"timestamp": "2024-04-22T14:38:04.675Z",
"actor": {
"account": {
"homePage": "https://users.yetanalytics.com",
"name": "placeholder"
}
},
"verb": {
"id": "https://xapinet.org/xapi/yet/calibration/v1/concepts#did",
"display": {
"en": "did"
}
},
"object": {
"id": "https://xapinet.org/xapi/yet/calibration/v1/concepts#activity-1",
"definition": {
"name": {
"en-US": "Activity 1"
},
"description": {
"en-US": "The first Activity"
}
}
},
"context": {
"registration": "44027e27-a976-41cb-9c10-a139e9e71fd3",
"contextActivities": {
"category": [
{
"id": "https://xapinet.org/xapi/yet/calibration/v1"
},
{
"id": "https://xapinet.org/xapi/yet/calibration_example/draft-c24f52fe-b3f8-40b7-b6c8-7328e2c74345"
}
]
}
}
}

32 changes: 30 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
import xapi
import json
from base64 import b64encode
import uuid
import concurrent.futures

# testing. Use LRS details below
response = xapi.post_file('sample-xapi.json', 'localhost', 'username', 'password', port=8080, protocol='http', batch=5)
print(response)
# response = xapi.post_file('sample-xapi.json', 'localhost', 'username', 'password', port=8080, protocol='http', batch=5)

f = open('template-xapi.json')
template_data = json.load(f)

def push_batch():
batch = []
for x in range(0, 150):
new_data = template_data
new_data['actor']['account']['name'] = str(uuid.uuid4())
batch.append(new_data)
response = xapi.post_xapi(batch, 'localhost', 'my_key', 'my_secret', port=8080, protocol='http', batch=150)
print('finished batch of 150')


print("got here")

threads = 20

for y in range(0, 1000):
with concurrent.futures.ThreadPoolExecutor(max_workers=threads) as executor:
for x in range(0, threads):
executor.submit(push_batch)
print('finished loop:' + str(y))

print("got here1")