Skip to content

Commit 59ce75b

Browse files
authored
Populate courserun_readable_id (#1749)
* populate courserun_readable_id * fix the column * update description
1 parent 5c6ac72 commit 59ce75b

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

src/ol_dbt/models/intermediate/learn-ai/_learn_ai__models.yml.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ models:
2424
- name: edx_module_id
2525
description: str, edX module ID for the chat session
2626
- name: courserun_readable_id
27-
description: str, the course ID for the chat session. May be blank for Canvas
28-
courses
27+
description: str, the course ID for the chat session
2928
- name: user_id
3029
description: int, user ID in learn AI application. Null if the user is not logged
3130
in.
@@ -70,7 +69,8 @@ models:
7069
- name: chatsession_object_id
7170
description: str, course ID or video transcript asset ID. May be blank for ResourceRecommendationBot.
7271
- name: courserun_readable_id
73-
description: str, the course readable ID for the chat session. Populated for VideoGPTBot.
72+
description: str, the course readable ID for the chat session. Populated for VideoGPTBot
73+
and TutorBot in a course context.
7474
- name: user_id
7575
description: int, user ID in learn AI application. Null if the user is not logged
7676
in.

src/ol_dbt/models/intermediate/learn-ai/int__learn_ai__chatbot.sql

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,17 @@ with chatsession as (
3838
)
3939
)
4040

41+
, problem as (
42+
select * from {{ ref('dim_problem') }}
43+
)
44+
4145
select
4246
djangocheckpoint.djangocheckpoint_id
4347
, djangocheckpoint.checkpoint_id
4448
, djangocheckpoint.chatsession_thread_id
4549
, chatsession.chatsession_agent
4650
, chatsession.chatsession_title
4751
, chatsession.chatsession_object_id
48-
, videos_with_ranking.courserun_readable_id
4952
, chatsession.user_id
5053
, users.user_email
5154
, users.user_full_name
@@ -62,10 +65,16 @@ select
6265
, djangocheckpoint.checkpoint_type
6366
, chatsession.chatsession_created_on
6467
, chatsession.chatsession_updated_on
68+
, coalesce(
69+
chatsession.canvas_course_id
70+
, videos_with_ranking.courserun_readable_id
71+
, problem.courserun_readable_id
72+
) as courserun_readable_id
6573
from djangocheckpoint
6674
inner join chatsession on djangocheckpoint.chatsession_thread_id = chatsession.chatsession_thread_id
6775
left join users on chatsession.user_id = users.user_id
6876
left join videos_with_ranking
6977
on
7078
chatsession.chatsession_object_id = videos_with_ranking.chatsession_object_id
7179
and videos_with_ranking.row_num = 1
80+
left join problem on chatsession.chatsession_object_id = problem.problem_block_pk

src/ol_dbt/models/intermediate/learn-ai/int__learn_ai__tutorbot.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ select
2121
, chatsession.chatsession_agent
2222
, chatsession.chatsession_title
2323
, chatsession.chatsession_object_id as edx_module_id
24-
, problem.courserun_readable_id
24+
, coalesce(chatsession.canvas_course_id, problem.courserun_readable_id) as courserun_readable_id
2525
, chatsession.user_id
2626
, users.user_email
2727
, users.user_full_name

src/ol_dbt/models/staging/learn-ai/_stg_learn_ai__models.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ models:
7272
- name: chatsession_object_id
7373
description: str, course ID, video transcript asset ID, or edX module ID depending
7474
on the chatsession_agent. May be blank for ResourceRecommendationBot.
75+
- name: canvas_course_id
76+
description: str, Canvas course ID for the chat session, e.g. 34625-15.060_FA25
77+
May be blank for non-Canvas
7578
- name: chatsession_django_session_key
7679
description: str, Django session key for the chat session.
7780
- name: chatsession_created_on

src/ol_dbt/models/staging/learn-ai/stg__learn_ai__app__postgres__chatbots_userchatsession.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ with source as (
1111
, user_id
1212
, thread_id as chatsession_thread_id
1313
, object_id as chatsession_object_id
14+
, if(object_id like '%+canvas%', split_part(object_id, '+canvas', 1), null) as canvas_course_id
1415
, dj_session_key as chatsession_django_session_key
1516
, {{ cast_timestamp_to_iso8601('created_on') }} as chatsession_created_on
1617
, {{ cast_timestamp_to_iso8601('updated_on') }} as chatsession_updated_on

0 commit comments

Comments
 (0)