From a60ee21f3a85aa3ae983fb2ab15792ac7bbb8b47 Mon Sep 17 00:00:00 2001 From: jo-elimu <1451036+jo-elimu@users.noreply.github.com> Date: Sat, 21 Sep 2024 12:34:57 +0700 Subject: [PATCH] feat: simulate video learning events Resolves #3 --- ...01018_video-learning-events_2024-09-21.csv | 13 +++++++++++ ...01018_video-learning-events_2024-09-21.csv | 18 +++++++++++++++ ...01018_video-learning-events_2024-09-21.csv | 17 ++++++++++++++ ...01018_video-learning-events_2024-09-21.csv | 2 ++ ...01018_video-learning-events_2024-09-21.csv | 14 +++++++++++ ...01018_video-learning-events_2024-09-21.csv | 20 ++++++++++++++++ simulate-video-learning-events.py | 23 +++++++++++++++---- 7 files changed, 102 insertions(+), 5 deletions(-) create mode 100644 lang-ENG/android-id-e387e38700000001/version-code-3001018/video-learning-events/e387e38700000001_3001018_video-learning-events_2024-09-21.csv create mode 100644 lang-ENG/android-id-e387e38700000002/version-code-3001018/video-learning-events/e387e38700000002_3001018_video-learning-events_2024-09-21.csv create mode 100644 lang-ENG/android-id-e387e38700000003/version-code-3001018/video-learning-events/e387e38700000003_3001018_video-learning-events_2024-09-21.csv create mode 100644 lang-TGL/android-id-e387e38700000001/version-code-3001018/video-learning-events/e387e38700000001_3001018_video-learning-events_2024-09-21.csv create mode 100644 lang-TGL/android-id-e387e38700000002/version-code-3001018/video-learning-events/e387e38700000002_3001018_video-learning-events_2024-09-21.csv create mode 100644 lang-TGL/android-id-e387e38700000003/version-code-3001018/video-learning-events/e387e38700000003_3001018_video-learning-events_2024-09-21.csv diff --git a/lang-ENG/android-id-e387e38700000001/version-code-3001018/video-learning-events/e387e38700000001_3001018_video-learning-events_2024-09-21.csv b/lang-ENG/android-id-e387e38700000001/version-code-3001018/video-learning-events/e387e38700000001_3001018_video-learning-events_2024-09-21.csv new file mode 100644 index 0000000..b73b66a --- /dev/null +++ b/lang-ENG/android-id-e387e38700000001/version-code-3001018/video-learning-events/e387e38700000001_3001018_video-learning-events_2024-09-21.csv @@ -0,0 +1,13 @@ +id,timestamp,android_id,package_name,video_id,video_title,learning_event_type +0,1726896840,e387e38700000001,ai.elimu.analytics,3,akili and me - letter c, +0,1726896840,e387e38700000001,ai.elimu.analytics,42,one small step, +0,1726896840,e387e38700000001,ai.elimu.analytics,13,akili and me - the rectangle song, +0,1726896840,e387e38700000001,ai.elimu.analytics,8,akili and me - family, +0,1726896840,e387e38700000001,ai.elimu.analytics,3,akili and me - letter c, +0,1726896840,e387e38700000001,ai.elimu.analytics,42,one small step, +0,1726896840,e387e38700000001,ai.elimu.analytics,8,akili and me - family, +0,1726896840,e387e38700000001,ai.elimu.analytics,10,akili and me - music, +0,1726896840,e387e38700000001,ai.elimu.analytics,33,akili and me - letter i, +0,1726896840,e387e38700000001,ai.elimu.analytics,3,akili and me - letter c, +0,1726896840,e387e38700000001,ai.elimu.analytics,36,akili and me - letter l, +0,1726896840,e387e38700000001,ai.elimu.analytics,34,akili and me - letter j, diff --git a/lang-ENG/android-id-e387e38700000002/version-code-3001018/video-learning-events/e387e38700000002_3001018_video-learning-events_2024-09-21.csv b/lang-ENG/android-id-e387e38700000002/version-code-3001018/video-learning-events/e387e38700000002_3001018_video-learning-events_2024-09-21.csv new file mode 100644 index 0000000..c6deb62 --- /dev/null +++ b/lang-ENG/android-id-e387e38700000002/version-code-3001018/video-learning-events/e387e38700000002_3001018_video-learning-events_2024-09-21.csv @@ -0,0 +1,18 @@ +id,timestamp,android_id,package_name,video_id,video_title,learning_event_type +0,1726896840,e387e38700000002,ai.elimu.analytics,42,one small step, +0,1726896840,e387e38700000002,ai.elimu.analytics,7,akili and me - letter g, +0,1726896840,e387e38700000002,ai.elimu.analytics,2,akili and me - letter b, +0,1726896840,e387e38700000002,ai.elimu.analytics,5,akili and me - letter e, +0,1726896840,e387e38700000002,ai.elimu.analytics,4,akili and me - letter d, +0,1726896840,e387e38700000002,ai.elimu.analytics,14,akili and me - counting compilation, +0,1726896840,e387e38700000002,ai.elimu.analytics,7,akili and me - letter g, +0,1726896840,e387e38700000002,ai.elimu.analytics,10,akili and me - music, +0,1726896840,e387e38700000002,ai.elimu.analytics,35,akili and me - letter k, +0,1726896840,e387e38700000002,ai.elimu.analytics,11,akili and me - art - drawing rectangles, +0,1726896840,e387e38700000002,ai.elimu.analytics,13,akili and me - the rectangle song, +0,1726896840,e387e38700000002,ai.elimu.analytics,9,akili and me - jump jump jump, +0,1726896840,e387e38700000002,ai.elimu.analytics,13,akili and me - the rectangle song, +0,1726896840,e387e38700000002,ai.elimu.analytics,1,akili and me - letter a, +0,1726896840,e387e38700000002,ai.elimu.analytics,5,akili and me - letter e, +0,1726896840,e387e38700000002,ai.elimu.analytics,10,akili and me - music, +0,1726896840,e387e38700000002,ai.elimu.analytics,33,akili and me - letter i, diff --git a/lang-ENG/android-id-e387e38700000003/version-code-3001018/video-learning-events/e387e38700000003_3001018_video-learning-events_2024-09-21.csv b/lang-ENG/android-id-e387e38700000003/version-code-3001018/video-learning-events/e387e38700000003_3001018_video-learning-events_2024-09-21.csv new file mode 100644 index 0000000..67fd11a --- /dev/null +++ b/lang-ENG/android-id-e387e38700000003/version-code-3001018/video-learning-events/e387e38700000003_3001018_video-learning-events_2024-09-21.csv @@ -0,0 +1,17 @@ +id,timestamp,android_id,package_name,video_id,video_title,learning_event_type +0,1726896840,e387e38700000003,ai.elimu.analytics,7,akili and me - letter g, +0,1726896840,e387e38700000003,ai.elimu.analytics,33,akili and me - letter i, +0,1726896840,e387e38700000003,ai.elimu.analytics,9,akili and me - jump jump jump, +0,1726896840,e387e38700000003,ai.elimu.analytics,12,akili and me - numbers - one two three song, +0,1726896840,e387e38700000003,ai.elimu.analytics,2,akili and me - letter b, +0,1726896840,e387e38700000003,ai.elimu.analytics,14,akili and me - counting compilation, +0,1726896840,e387e38700000003,ai.elimu.analytics,6,akili and me - letter f, +0,1726896840,e387e38700000003,ai.elimu.analytics,14,akili and me - counting compilation, +0,1726896840,e387e38700000003,ai.elimu.analytics,42,one small step, +0,1726896840,e387e38700000003,ai.elimu.analytics,12,akili and me - numbers - one two three song, +0,1726896840,e387e38700000003,ai.elimu.analytics,14,akili and me - counting compilation, +0,1726896840,e387e38700000003,ai.elimu.analytics,10,akili and me - music, +0,1726896840,e387e38700000003,ai.elimu.analytics,8,akili and me - family, +0,1726896840,e387e38700000003,ai.elimu.analytics,34,akili and me - letter j, +0,1726896840,e387e38700000003,ai.elimu.analytics,34,akili and me - letter j, +0,1726896840,e387e38700000003,ai.elimu.analytics,6,akili and me - letter f, diff --git a/lang-TGL/android-id-e387e38700000001/version-code-3001018/video-learning-events/e387e38700000001_3001018_video-learning-events_2024-09-21.csv b/lang-TGL/android-id-e387e38700000001/version-code-3001018/video-learning-events/e387e38700000001_3001018_video-learning-events_2024-09-21.csv new file mode 100644 index 0000000..ae81beb --- /dev/null +++ b/lang-TGL/android-id-e387e38700000001/version-code-3001018/video-learning-events/e387e38700000001_3001018_video-learning-events_2024-09-21.csv @@ -0,0 +1,2 @@ +id,timestamp,android_id,package_name,video_id,video_title,learning_event_type +0,1726896842,e387e38700000001,ai.elimu.analytics,1,piper, diff --git a/lang-TGL/android-id-e387e38700000002/version-code-3001018/video-learning-events/e387e38700000002_3001018_video-learning-events_2024-09-21.csv b/lang-TGL/android-id-e387e38700000002/version-code-3001018/video-learning-events/e387e38700000002_3001018_video-learning-events_2024-09-21.csv new file mode 100644 index 0000000..c02762a --- /dev/null +++ b/lang-TGL/android-id-e387e38700000002/version-code-3001018/video-learning-events/e387e38700000002_3001018_video-learning-events_2024-09-21.csv @@ -0,0 +1,14 @@ +id,timestamp,android_id,package_name,video_id,video_title,learning_event_type +0,1726896842,e387e38700000002,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000002,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000002,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000002,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000002,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000002,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000002,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000002,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000002,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000002,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000002,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000002,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000002,ai.elimu.analytics,1,piper, diff --git a/lang-TGL/android-id-e387e38700000003/version-code-3001018/video-learning-events/e387e38700000003_3001018_video-learning-events_2024-09-21.csv b/lang-TGL/android-id-e387e38700000003/version-code-3001018/video-learning-events/e387e38700000003_3001018_video-learning-events_2024-09-21.csv new file mode 100644 index 0000000..1e37241 --- /dev/null +++ b/lang-TGL/android-id-e387e38700000003/version-code-3001018/video-learning-events/e387e38700000003_3001018_video-learning-events_2024-09-21.csv @@ -0,0 +1,20 @@ +id,timestamp,android_id,package_name,video_id,video_title,learning_event_type +0,1726896842,e387e38700000003,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000003,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000003,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000003,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000003,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000003,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000003,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000003,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000003,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000003,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000003,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000003,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000003,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000003,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000003,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000003,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000003,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000003,ai.elimu.analytics,1,piper, +0,1726896842,e387e38700000003,ai.elimu.analytics,1,piper, diff --git a/simulate-video-learning-events.py b/simulate-video-learning-events.py index 5877928..d8e87f1 100644 --- a/simulate-video-learning-events.py +++ b/simulate-video-learning-events.py @@ -23,7 +23,8 @@ date_iso_8601 = datetime.today().strftime('%Y-%m-%d') print(basename(__file__), f'date_iso_8601: {date_iso_8601}') -def simulateVideoLearningEvent(android_id): +def simulate_video_learning_event(android_id, videos_df: pandas.DataFrame): + print(basename(__file__), 'simulate_video_learning_event') """ Simulate a VideoLearningEvent, e.g. a video being opened. @@ -33,12 +34,19 @@ def simulateVideoLearningEvent(android_id): id = 0 timestamp = int(datetime.now().timestamp()) + # Locate a random video in the DataFrame + number_of_videos = len(videos_df.index) + random_video_index = random.randrange(0, number_of_videos) + random_video = videos_df.loc[random_video_index] + return { 'id': id, 'timestamp': timestamp, 'android_id': android_id, 'package_name': package_name, - 'video_id': 0 + 'video_id': random_video.id, + 'video_title': random_video.title, + 'learning_event_type': '' } for language_code in language_codes: @@ -49,6 +57,11 @@ def simulateVideoLearningEvent(android_id): print(basename(__file__), f'videos_csv_url: {videos_csv_url}') videos_df = pandas.read_csv(videos_csv_url) print(basename(__file__), f'videos_df: \n{videos_df}') + number_of_videos = len(videos_df.index) + print(basename(__file__), f'number_of_videos: {number_of_videos}') + if (number_of_videos == 0): + print(basename(__file__), 'Zero videos. Skipping event simulation.') + continue base_url = f'http://{language_code.lower()}.elimu.ai' print(basename(__file__), f'base_url: {base_url}') @@ -65,12 +78,12 @@ def simulateVideoLearningEvent(android_id): 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}') + event = simulate_video_learning_event(android_id, videos_df) + # 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}') + # print(basename(__file__), f'video_learning_events_df: \n{video_learning_events_df}') # Export to CSV language_dir = f'lang-{language_code}'