Skip to content

Commit

Permalink
Updating unique learner count query (#2234)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanbossenger authored Feb 21, 2024
1 parent 05c1e24 commit 9619ad6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions wp-content/plugins/wporg-learn/inc/sensei.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,12 @@ function wporg_learn_get_student_count( $from_date, $to_date ) {

return $wpdb->get_var(
$wpdb->prepare(
"SELECT COUNT(DISTINCT user_id) FROM $wpdb->comments
WHERE comment_type = 'sensei_course_status'
AND comment_date_gmt >= %s
AND comment_date_gmt <= %s",
"SELECT COUNT(DISTINCT user_id) FROM $wpdb->comments as c
INNER JOIN $wpdb->commentmeta AS cm ON c.comment_ID = cm.comment_id
WHERE c.comment_type = 'sensei_course_status'
AND cm.meta_key = 'start'
AND cm.meta_value >= %s
AND cm.meta_value <= %s",
array(
$from_date->format( 'Y-m-d H:i:s' ),
$to_date->format( 'Y-m-d H:i:s' ),
Expand Down

0 comments on commit 9619ad6

Please sign in to comment.