class RevisionAnalyticsService

  def self.dyk_eligible
    Article
      .eager_load(:revisions)
      .eager_load(:courses)
      .references(:all)
      .where{ revisions.wp10 > 5 }
      .where{(namespace == 118) | ((namespace == 2) & (title !~ '%/%'))}
  end

end

class RevisionAnalyticsService

  def self.dyk_eligible
    current_course_ids = Course.current.pluck(:id)
    current_student_ids = CoursesUsers
                          .where(course_id: current_course_ids, role: 0)
                          .pluck(:user_id)
    Article
      .eager_load(:revisions)
      .where { revisions.wp10 > 30 }
      .where(revisions: { user_id: current_student_ids })
      .where { (namespace == 118) | ((namespace == 2) & ('title like %/%')) }
  end
end

Update query for DYK feed
Update query for DYK feed

ArticlesCourses generally only get created for mainspace pages, so we can't use them as an indicator that a page is connected to a current course.
