-
-
Save lane-eb/40241696ab4d0819944d9bb8b30d79c7 to your computer and use it in GitHub Desktop.
Django query solution to replace `values_list('repo__name')`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# IMO, This is the best. | |
def contributor_repo_names(self, organization): | |
repo_ids = Commit.objects.filter( | |
repo__in=organization.repos.all(), | |
committer=self | |
).values_list('repo_id', flat=True).distinct('repo_id') | |
return list( | |
GitRepo.objects.filter(repo_id__in=repo_ids).values_list('name', flat=True) | |
) | |
# IMO, This is not as good as the previous one. | |
def contributor_repo_names(self, organization): | |
return list(Commit.objects.filter(repo__in=organization.repos.all(), | |
committer=self) | |
.values_list('repo__name', flat=True).distinct('repo_id')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment