Skip to content

Commit

Permalink
fix: update prepared learners query
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammad-ammar committed Feb 23, 2024
1 parent d6c7ac9 commit ff3be85
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 31 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Unreleased
~~~~~~~~~~


[2.5.1] - 2024-02-22
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Update prepared learners query

[2.5.0] - 2023-11-02
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Add management command to trigger segment events for learners who have achieved 30 minutes of learning
Expand Down
2 changes: 1 addition & 1 deletion outcome_surveys/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
Outcome Surveys.
"""

__version__ = '2.5.0'
__version__ = '2.5.1'

default_app_config = 'outcome_surveys.apps.OutcomeSurveysConfig' # pylint: disable=invalid-name
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,25 @@

ENTERPRISE = settings.ENTERPRISE_VSF_UUID
QUERY = f'''
WITH prepared_learners as (
-- get users who have hit :30
-- minutes threshold, but haven't been
-- surveyed yet.
SELECT
user_id,
SUM(learning_time_seconds) as learning_time_seconds
FROM
PROD.BUSINESS_INTELLIGENCE.LEARNING_TIME
WHERE
enterprise_customer_uuid='{ENTERPRISE}'
AND
user_id not in (
-- filter learners who already emitted this event.
SELECT
user_id
FROM
PROD.LMS.OUTCOME_SURVEYS_LEARNERCOURSEEVENT
WHERE
event_type = 'edx.course.learner.achieved.learning.time'
AND
already_sent = TRUE
)
GROUP BY
user_id
HAVING
-- filter learners who haven't hit the threshold.
SUM(learning_time_seconds) >= 1800
WITH prepared_learners AS (
SELECT
lms_user_id as user_id
FROM
prod.enterprise.verizon_internal_reporting
WHERE
is_prepared_learner=TRUE
AND
lms_user_id NOT IN (
-- filter learners who already emitted this event
SELECT
user_id
FROM
PROD.LMS.OUTCOME_SURVEYS_LEARNERCOURSEEVENT
WHERE
event_type = 'edx.course.learner.achieved.learning.time'
AND
already_sent = TRUE
)
),
last_course as (
Expand All @@ -73,13 +64,12 @@
-- join it all together.
select
pl.user_id,
pl.learning_time_seconds,
runs.courserun_key,
runs.course_key,
runs.courserun_title
from
prepared_learners pl
left join
inner join
last_course lc
on
pl.user_id = lc.user_id
Expand Down

0 comments on commit ff3be85

Please sign in to comment.