Skip to content

Commit

Permalink
Merge pull request #981 from openedx/cag/actor-as-email
Browse files Browse the repository at this point in the history
fix: parse external_id to string instead of actor_id to uuid
  • Loading branch information
Cristhian Garcia authored Nov 1, 2024
2 parents 866f4c0 + 9976417 commit fb09429
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \
pip install "platform-plugin-aspects==v0.11.3"
pip install "platform-plugin-aspects==v0.11.4"

RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \
pip install "edx-event-routing-backends>=9.3.0,<9.4"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \
pip install "platform-plugin-aspects==v0.11.3"
pip install "platform-plugin-aspects==v0.11.4"

RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \
pip install "edx-event-routing-backends>=9.3.0,<9.4"
2 changes: 1 addition & 1 deletion tutoraspects/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@
# For now we are pulling this from github, which should allow maximum
# flexibility for forking, running branches, specific versions, etc.
("DBT_REPOSITORY", "https://github.com/openedx/aspects-dbt"),
("DBT_BRANCH", "v3.33.3"),
("DBT_BRANCH", "v3.33.5"),
("DBT_SSH_KEY", ""),
("DBT_STATE_DIR", "/app/aspects-dbt/state"),
("DBT_PROFILES_DIR", "/app/aspects/dbt/"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from alembic import op
import sqlalchemy as sa

revision = "0040"
down_revision = "0039"
branch_labels = None
depends_on = None
on_cluster = " ON CLUSTER '{{CLICKHOUSE_CLUSTER_NAME}}' " if "{{CLICKHOUSE_CLUSTER_NAME}}" else ""
engine = (
"ReplicatedReplacingMergeTree"
if "{{CLICKHOUSE_CLUSTER_NAME}}"
else "ReplacingMergeTree"
)



def upgrade():
op.execute(
f"""
ALTER TABLE {{ ASPECTS_EVENT_SINK_DATABASE }}.user_profile
{on_cluster}
ADD COLUMN IF NOT EXISTS username String DEFAULT ''
AFTER name;
"""
)


def downgrade():
op.execute(
f"""
ALTER TABLE {{ ASPECTS_EVENT_SINK_DATABASE }}.user_profile
{on_cluster}
DROP COLUMN IF EXISTS username;
"""
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# alembic packages
alembic==1.11.1
clickhouse-sqlalchemy==0.1.9
git+https://github.com/openedx/[email protected]
git+https://github.com/openedx/[email protected].1
pyyaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ select
from enrollments
inner join
{{ DBT_PROFILE_TARGET_DATABASE }}.dim_user_pii as users
on enrollments.actor_id = users.external_user_id::String
on (
enrollments.actor_id like 'mailto:%'
and SUBSTRING(enrollments.actor_id, 8) = users.email
)
or enrollments.actor_id = toString(users.external_user_id)
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ join
)
left outer join
{{ DBT_PROFILE_TARGET_DATABASE }}.dim_user_pii users
on toUUID(pv.actor_id) = users.external_user_id
on (pv.actor_id like 'mailto:%' and SUBSTRING(pv.actor_id, 8) = users.email)
or pv.actor_id = toString(users.external_user_id)
where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %}
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ join
)
left outer join
{{ DBT_PROFILE_TARGET_DATABASE }}.dim_user_pii users
on toUUID(pe.actor_id) = users.external_user_id
on (pe.actor_id like 'mailto:%' and SUBSTRING(pe.actor_id, 8) = users.email)
or pe.actor_id = toString(users.external_user_id)
where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %}
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ join
)
left outer join
{{ DBT_PROFILE_TARGET_DATABASE }}.dim_user_pii users
on toUUID(ve.actor_id) = users.external_user_id
on (ve.actor_id like 'mailto:%' and SUBSTRING(ve.actor_id, 8) = users.email)
or ve.actor_id = toString(users.external_user_id)
where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %}
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,6 @@ select
from enriched_segments
left outer join
{{ DBT_PROFILE_TARGET_DATABASE }}.dim_user_pii users
on toUUID(actor_id) = users.external_user_id
on (actor_id like 'mailto:%' and SUBSTRING(actor_id, 8) = users.email)
or actor_id = toString(users.external_user_id)
order by segment_start
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,10 @@ join
)
left outer join
{{ ASPECTS_EVENT_SINK_DATABASE }}.user_pii users
on full_responses.actor_id = users.external_user_id::String
on (
full_responses.actor_id like 'mailto:%'
and SUBSTRING(full_responses.actor_id, 8) = users.email
)
or full_responses.actor_id = toString(users.external_user_id)

where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ join
)
left outer join
{{ ASPECTS_EVENT_SINK_DATABASE }}.user_pii users
on full_responses.actor_id = users.external_user_id::String
on (
full_responses.actor_id like 'mailto:%'
and SUBSTRING(full_responses.actor_id, 8) = users.email
)
or full_responses.actor_id = toString(users.external_user_id)
join
coursewide_attempts
on full_responses.org = coursewide_attempts.org
Expand Down

0 comments on commit fb09429

Please sign in to comment.