Skip to content

Commit

Permalink
Merge pull request #130 from nelc/and/fix_external_id_searches
Browse files Browse the repository at this point in the history
fix: parse external_id to string instead of actor id to uuid and allo…
  • Loading branch information
Cristhian Garcia authored Oct 31, 2024
2 parents ee5b022 + b4dc921 commit 4139d69
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 7 deletions.
4 changes: 3 additions & 1 deletion models/enrollment/fact_enrollments.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ select
from enrollments
join {{ ref("course_names") }} courses on enrollments.course_key = courses.course_key
left outer join
{{ ref("dim_user_pii") }} users on toUUID(actor_id) = users.external_user_id
{{ ref("dim_user_pii") }} users
on (actor_id like 'mailto:%' and SUBSTRING(actor_id, 8) = users.email)
or actor_id = toString(users.external_user_id)
4 changes: 3 additions & 1 deletion models/grading/fact_student_status.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ join
on fes.org = courses.org
and fes.course_key = courses.course_key
left outer join
{{ ref("dim_user_pii") }} users on toUUID(actor_id) = users.external_user_id
{{ ref("dim_user_pii") }} users
on (actor_id like 'mailto:%' and SUBSTRING(actor_id, 8) = users.email)
or actor_id = toString(users.external_user_id)
4 changes: 3 additions & 1 deletion models/navigation/fact_navigation.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ join
and navigation.block_id = blocks.block_id
)
left outer join
{{ ref("dim_user_pii") }} users on toUUID(actor_id) = users.external_user_id
{{ ref("dim_user_pii") }} users
on (actor_id like 'mailto:%' and SUBSTRING(actor_id, 8) = users.email)
or actor_id = toString(users.external_user_id)
4 changes: 3 additions & 1 deletion models/navigation/fact_pageview_engagement.sql
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ join
and pv.block_id = course_blocks.block_id
)
left outer join
{{ ref("dim_user_pii") }} users on toUUID(pv.actor_id) = users.external_user_id
{{ ref("dim_user_pii") }} users
on (pv.actor_id like 'mailto:%' and SUBSTRING(pv.actor_id, 8) = users.email)
or pv.actor_id = toString(users.external_user_id)
4 changes: 3 additions & 1 deletion models/problems/fact_problem_responses.sql
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ join
and responses.problem_id = blocks.block_id
)
left outer join
{{ ref("dim_user_pii") }} users on toUUID(actor_id) = users.external_user_id
{{ ref("dim_user_pii") }} users
on (actor_id like 'mailto:%' and SUBSTRING(actor_id, 8) = users.email)
or actor_id = toString(users.external_user_id)
group by
-- multi-part questions include an extra record for the response to the first
-- part of the question. this group by clause eliminates the duplicate record
Expand Down
4 changes: 3 additions & 1 deletion models/video/fact_video_engagement.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ join
and ve.block_id = course_blocks.block_id
)
left outer join
{{ ref("dim_user_pii") }} users on toUUID(ve.actor_id) = users.external_user_id
{{ ref("dim_user_pii") }} users
on (ve.actor_id like 'mailto:%' and SUBSTRING(ve.actor_id, 8) = users.email)
or ve.actor_id = toString(users.external_user_id)
4 changes: 3 additions & 1 deletion models/video/fact_video_plays.sql
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ join
{{ ref("dim_course_blocks_extended") }} blocks
on (plays.course_key = blocks.course_key and plays.video_id = blocks.block_id)
left outer join
{{ ref("dim_user_pii") }} users on toUUID(actor_id) = users.external_user_id
{{ ref("dim_user_pii") }} users
on (actor_id like 'mailto:%' and SUBSTRING(actor_id, 8) = users.email)
or actor_id = toString(users.external_user_id)

0 comments on commit 4139d69

Please sign in to comment.