Skip to content

Instantly share code, notes, and snippets.

@talum
Last active November 25, 2018 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talum/3ddd742ba8259655b83a9af819d5d696 to your computer and use it in GitHub Desktop.
Save talum/3ddd742ba8259655b83a9af819d5d696 to your computer and use it in GitHub Desktop.
STI examples
def completed_labs_count(student, canonical_repo_ids)
if $rollout.active?(:remove_content)
student.canonical_progresses.complete.
joins(github_repository: :canonical_material).
where(github_repository_id: canonical_repo_ids).
where(kind: CourseWork::CanonicalMaterial::LAB_KINDS).
uniq(:id).
count
else
student.canonical_progresses.complete.
joins(github_repository: :contents).
where(github_repository_id: canonical_repo_ids).
where(contents: { type: 'Lab' }).
uniq(:id).
count
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment