Skip to content

Commit

Permalink
feat: simulate video learning events
Browse files Browse the repository at this point in the history
Resolves #3
  • Loading branch information
jo-elimu committed Sep 21, 2024
1 parent 18b9a86 commit e66900c
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
id,time
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
id,time
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id,time
0,0
0,0
0,0
0,0
0,0
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
id,time
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id,time
0,0
0,0
0,0
0,0
0,0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,time
0,0
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id,time
0,0
0,0
0,0
0,0
0,0
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
id,time
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
id,time
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
0,0
43 changes: 37 additions & 6 deletions simulate-video-learning-events.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from datetime import datetime
import os
from os.path import basename
import pandas
import random

language_codes = ['ENG', 'HIN', 'TGL']
print(basename(__file__), f'language_codes: {language_codes}')
Expand All @@ -12,12 +15,23 @@
analytics_version_code = 3001018
print(basename(__file__), f'analytics_version_code: {analytics_version_code}')

date = datetime.today().strftime('%Y-%m-%d')
print(basename(__file__), f'date: {date}')

def simulateVideoLearningEvent(android_id):
"""Simulate a VideoLearningEvent, e.g. a video being opened."""
"""
Simulate a VideoLearningEvent, e.g. a video being opened.
Should match the CSV format in https://github.com/elimu-ai/analytics/blob/main/app/src/main/java/ai/elimu/analytics/task/ExportEventsToCsvWorker.java
"""

# TODO
id = 0
time = 0

return {}
return {
'id': id,
'time': time
}

for language_code in language_codes:
print(basename(__file__))
Expand All @@ -38,8 +52,25 @@ def simulateVideoLearningEvent(android_id):
print(basename(__file__))
print(basename(__file__), f'android_id: {android_id}')

event = simulateVideoLearningEvent(android_id)
print(basename(__file__), f'event: {event}')
video_learning_events = []
random_number_of_events = random.randrange(0, 20)
print(basename(__file__), f'random_number_of_events: {random_number_of_events}')
for i in range(random_number_of_events):
print(basename(__file__))
event = simulateVideoLearningEvent(android_id)
print(basename(__file__), f'event: {event}')
video_learning_events.append(event)

video_learning_events_df = pandas.DataFrame(video_learning_events)
print(basename(__file__), f'video_learning_events_df: \n{video_learning_events_df}')

# Export to CSV
# TODO
language_dir = f'lang-{language_code}'
android_id_dir = os.path.join(language_dir, f'android-id-{android_id}')
version_code_dir = os.path.join(android_id_dir, f'version-code-{analytics_version_code}')
storybook_learning_events_dir = os.path.join(version_code_dir, f'storybook-learning-events')
if not os.path.exists(storybook_learning_events_dir):
os.makedirs(storybook_learning_events_dir)
csv_path = os.path.join(storybook_learning_events_dir, f'{android_id}_{analytics_version_code}_storybook-learning-events_{date}.csv')
print(basename(__file__), f'csv_path: \n{csv_path}')
video_learning_events_df.to_csv(csv_path, index=False)

0 comments on commit e66900c

Please sign in to comment.