Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit 67f8b5d

Browse files
feat: New properties for owner repos (#1168)
1 parent ade58e2 commit 67f8b5d

File tree

5 files changed

+47
-4
lines changed

5 files changed

+47
-4
lines changed

graphql_api/tests/test_owner.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,12 +718,37 @@ def test_owner_query_with_private_repos(self):
718718
query = """{
719719
owner(username: "%s") {
720720
hasPrivateRepos
721+
hasPublicRepos
722+
hasActiveRepos
721723
}
722724
}
723725
""" % (current_org.username)
724726

725727
data = self.gql_request(query, owner=current_org)
726728
assert data["owner"]["hasPrivateRepos"] == True
729+
assert data["owner"]["hasPublicRepos"] == False
730+
assert data["owner"]["hasActiveRepos"] == True
731+
732+
def test_owner_query_with_no_active_repos(self):
733+
current_org = OwnerFactory(
734+
username="random-plan-user",
735+
service="github",
736+
)
737+
RepositoryFactory(
738+
author=current_org, active=False, activated=False, private=True
739+
)
740+
query = """{
741+
owner(username: "%s") {
742+
hasPrivateRepos
743+
hasPublicRepos
744+
hasActiveRepos
745+
}
746+
}
747+
""" % (current_org.username)
748+
data = self.gql_request(query, owner=current_org)
749+
assert data["owner"]["hasPrivateRepos"] == True
750+
assert data["owner"]["hasPublicRepos"] == False
751+
assert data["owner"]["hasActiveRepos"] == False
727752

728753
def test_owner_query_with_public_repos(self):
729754
current_org = OwnerFactory(
@@ -747,12 +772,16 @@ def test_owner_query_with_public_repos(self):
747772
query = """{
748773
owner(username: "%s") {
749774
hasPrivateRepos
775+
hasPublicRepos
776+
hasActiveRepos
750777
}
751778
}
752779
""" % (current_org.username)
753780

754781
data = self.gql_request(query, owner=current_org)
755782
assert data["owner"]["hasPrivateRepos"] == False
783+
assert data["owner"]["hasPublicRepos"] == True
784+
assert data["owner"]["hasActiveRepos"] == True
756785

757786
def test_owner_hash_owner_id(self):
758787
user = OwnerFactory(username="sample-user")

graphql_api/types/owner/owner.graphql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ type Owner {
66
defaultOrgUsername: String
77
delinquent: Boolean
88
hashOwnerid: String
9+
hasActiveRepos: Boolean
910
hasPrivateRepos: Boolean
11+
hasPublicRepos: Boolean
1012
invoice(invoiceId: String!): Invoice
1113
invoices: [Invoice] @cost(complexity: 100)
1214
isAdmin: Boolean

graphql_api/types/owner/owner.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,20 @@ def resolve_has_private_repos(owner: Owner, info: GraphQLResolveInfo) -> bool:
133133
return owner.has_private_repos
134134

135135

136+
@owner_bindable.field("hasPublicRepos")
137+
@sync_to_async
138+
@require_part_of_org
139+
def resolve_has_public_repos(owner: Owner, info: GraphQLResolveInfo) -> bool:
140+
return owner.has_public_repos
141+
142+
143+
@owner_bindable.field("hasActiveRepos")
144+
@sync_to_async
145+
@require_part_of_org
146+
def resolve_has_active_repos(owner: Owner, info: GraphQLResolveInfo) -> bool:
147+
return owner.has_active_repos
148+
149+
136150
@owner_bindable.field("ownerid")
137151
@require_part_of_org
138152
def resolve_ownerid(owner: Owner, info: GraphQLResolveInfo) -> int:

requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ freezegun
2525
google-cloud-pubsub
2626
gunicorn>=22.0.0
2727
https://github.com/codecov/opentelem-python/archive/refs/tags/v0.0.4a1.tar.gz#egg=codecovopentelem
28-
https://github.com/codecov/shared/archive/04b5f811bd64eb67acff23d89300a988b1c3e61e.tar.gz#egg=shared
28+
https://github.com/codecov/shared/archive/fa8b61e956580068997e1c04bad0d4dc29ad3ea3.tar.gz#egg=shared
2929
https://github.com/photocrowd/django-cursor-pagination/archive/f560902696b0c8509e4d95c10ba0d62700181d84.tar.gz
3030
idna>=3.7
3131
minio

requirements.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,6 @@ googleapis-common-protos[grpc]==1.59.1
202202
# grpcio-status
203203
graphql-core==3.2.3
204204
# via ariadne
205-
greenlet==3.1.1
206-
# via sqlalchemy
207205
grpc-google-iam-v1==0.12.6
208206
# via google-cloud-pubsub
209207
grpcio==1.62.1
@@ -421,7 +419,7 @@ sentry-sdk[celery]==2.13.0
421419
# shared
422420
setproctitle==1.1.10
423421
# via -r requirements.in
424-
shared @ https://github.com/codecov/shared/archive/04b5f811bd64eb67acff23d89300a988b1c3e61e.tar.gz
422+
shared @ https://github.com/codecov/shared/archive/fa8b61e956580068997e1c04bad0d4dc29ad3ea3.tar.gz
425423
# via -r requirements.in
426424
simplejson==3.17.2
427425
# via -r requirements.in

0 commit comments

Comments
 (0)