Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0cb9d29
Initial commit
rohitvinnakota-codecov Jan 15, 2025
85caf80
Merge branch 'main' of https://github.com/codecov/codecov-api into rv…
rohitvinnakota-codecov Feb 11, 2025
7c0bf38
update
rohitvinnakota-codecov Feb 11, 2025
91fd9cd
Update tests
rohitvinnakota-codecov Feb 18, 2025
d047c5b
Update
rohitvinnakota-codecov Feb 18, 2025
f8e566c
Merge branch 'main' into rvinnakota/update-ai-repo
rohitvinnakota-codecov Feb 18, 2025
7111b1b
Update
rohitvinnakota-codecov Feb 18, 2025
87c2414
Merge branch 'rvinnakota/update-ai-repo' of https://github.com/codeco…
rohitvinnakota-codecov Feb 18, 2025
4601365
Lint
rohitvinnakota-codecov Feb 18, 2025
333ff4c
Update return type
rohitvinnakota-codecov Feb 18, 2025
3763fb7
CI headaches
rohitvinnakota-codecov Feb 18, 2025
d987ef7
Try new approach
rohitvinnakota-codecov Feb 20, 2025
de1f3de
Tests
rohitvinnakota-codecov Feb 20, 2025
30dfe70
Merge branch 'main' of https://github.com/codecov/codecov-api into rv…
rohitvinnakota-codecov Feb 20, 2025
1ef6d08
Undo
rohitvinnakota-codecov Feb 20, 2025
4dd984d
Sort
rohitvinnakota-codecov Feb 20, 2025
c0fd454
Update params
rohitvinnakota-codecov Feb 20, 2025
a54ff4f
Merge branch 'main' into rvinnakota/update-ai-repo
rohitvinnakota-codecov Feb 20, 2025
662df84
Try fix flakes
rohitvinnakota-codecov Feb 21, 2025
2404b9d
Merge branch 'rvinnakota/update-ai-repo' of https://github.com/codeco…
rohitvinnakota-codecov Feb 21, 2025
0c82122
Update tests
rohitvinnakota-codecov Feb 21, 2025
82bbbc9
lint
rohitvinnakota-codecov Feb 21, 2025
a7be526
Merge branch 'main' into rvinnakota/update-ai-repo
rohitvinnakota-codecov Feb 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions graphql_api/tests/test_owner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1202,3 +1202,46 @@ def test_fetch_available_plans_is_enterprise_plan(self):
]
}
}

@patch("services.self_hosted.get_config")
def test_ai_enabled_repositories(self, get_config_mock):
current_org = OwnerFactory(
username="random-plan-user",
service="github",
)

get_config_mock.return_value = [
{"service": "github", "ai_features_app_id": 12345},
]

query = """{
owner(username: "%s") {
aiEnabledRepos
}
}

""" % (current_org.username)
data = self.gql_request(query, owner=current_org)
assert data["owner"]["aiEnabledRepos"] is None


@patch("services.self_hosted.get_config")
def test_ai_enabled_repositories_app_not_configured(self, get_config_mock):
current_org = OwnerFactory(
username="random-plan-user",
service="github",
)

get_config_mock.return_value = [
{"service": "github", "ai_features_app_id": 12345},
]

query = """{
owner(username: "%s") {
aiEnabledRepos
}
}

""" % (current_org.username)
data = self.gql_request(query, owner=current_org)
assert data["owner"]["aiEnabledRepos"] is None
Comment thread
rohitvinnakota-codecov marked this conversation as resolved.
Outdated
Comment thread
rohitvinnakota-codecov marked this conversation as resolved.
Outdated
Comment thread
rohitvinnakota-codecov marked this conversation as resolved.
Outdated
Comment thread
rohitvinnakota-codecov marked this conversation as resolved.
Outdated
8 changes: 8 additions & 0 deletions graphql_api/types/owner/owner.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ type Owner {
yaml: String
aiFeaturesEnabled: Boolean!
aiEnabledRepos: [String]
aiEnabledRepositories(
ordering: RepositoryOrdering
orderingDirection: OrderingDirection
first: Int
after: String
last: Int
before: String
): RepositoryConnection! @cost(complexity: 25, multipliers: ["first", "last"])
Comment thread
rohitvinnakota-codecov marked this conversation as resolved.
Outdated
uploadTokenRequired: Boolean
activatedUserCount: Int
}
Comment thread
rohitvinnakota-codecov marked this conversation as resolved.
Outdated
30 changes: 30 additions & 0 deletions graphql_api/types/owner/owner.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,33 @@ def resolve_upload_token_required(
@require_shared_account_or_part_of_org
def resolve_activated_user_count(owner: Owner, info: GraphQLResolveInfo) -> int:
return owner.activated_user_count

@owner_bindable.field("aiEnabledRepositories")
def resolve_ai_enabled_repositories(
owner: Owner,
info: GraphQLResolveInfo,
ordering: Optional[RepositoryOrdering] = RepositoryOrdering.ID,
ordering_direction: Optional[OrderingDirection] = OrderingDirection.ASC,
**kwargs: Any,
) -> Coroutine[Any, Any, Connection]:
ai_features_app_install = GithubAppInstallation.objects.filter(
app_id=AI_FEATURES_GH_APP_ID, owner=owner
).first()

if not ai_features_app_install:
return None

current_owner = info.context["request"].current_owner
queryset = Repository.objects.filter(author=owner).viewable_repos(current_owner)

if ai_features_app_install.repository_service_ids:
queryset = queryset.filter(
service_id__in=ai_features_app_install.repository_service_ids
)

return queryset_to_connection(
queryset,
ordering=(ordering, RepositoryOrdering.ID),
ordering_direction=ordering_direction,
**kwargs,
)
Comment thread
rohitvinnakota-codecov marked this conversation as resolved.
Outdated
Comment thread
rohitvinnakota-codecov marked this conversation as resolved.
Outdated
Comment thread
rohitvinnakota-codecov marked this conversation as resolved.
Outdated