Skip to content

Commit

Permalink
Merge ab7f9af into ccd968f
Browse files Browse the repository at this point in the history
  • Loading branch information
victor-salles committed Aug 3, 2022
2 parents ccd968f + ab7f9af commit 845a7ae
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions bothub/api/v2/internal/organization/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.utils.translation import ugettext_lazy as _
from django.db import models
from rest_framework import mixins
from rest_framework.response import Response
from rest_framework.viewsets import GenericViewSet
Expand All @@ -8,9 +7,7 @@
from bothub.authentication.models import User
from bothub.common.models import (
Organization,
OrganizationAuthorization,
Repository,
RepositoryAuthorization,
OrganizationAuthorization
)
from bothub.api.v2.internal.organization.serializers import (
OrganizationSerializer,
Expand Down Expand Up @@ -102,19 +99,5 @@ def update(self, request, *args, **kwargs):

def retrieve(self, request, *args, **kwargs):
org = self.get_object()

auths = (
RepositoryAuthorization.objects.exclude(repository__owner=org)
.exclude(role=RepositoryAuthorization.ROLE_NOT_SETTED)
.filter(user=org)
)

response = {
"repositories_count": int(
Repository.objects.filter(
models.Q(uuid__in=auths) | models.Q(owner=org)
).count()
)
}

response = {"repositories_count": org.repositories.count()}
return Response(response)

0 comments on commit 845a7ae

Please sign in to comment.