MCPcopy Create free account
hub / github.com/cli/cli / SearchRepoAssignableActors

Function SearchRepoAssignableActors

api/queries_repo.go:1352–1410  ·  view source on GitHub ↗

SearchRepoAssignableActors searches assignable actors for a repository with an optional query string. Unlike RepoAssignableActors which fetches all actors with pagination, this returns up to 10 results matching the query, suitable for search-based selection.

(client *Client, repo ghrepo.Interface, query string)

Source from the content-addressed store, hash-verified

1350// query string. Unlike RepoAssignableActors which fetches all actors with pagination, this
1351// returns up to 10 results matching the query, suitable for search-based selection.
1352func SearchRepoAssignableActors(client *Client, repo ghrepo.Interface, query string) ([]AssignableActor, int, error) {
1353 type responseData struct {
1354 Repository struct {
1355 AssignableUsers struct {
1356 TotalCount int
1357 }
1358 SuggestedActors struct {
1359 Nodes []struct {
1360 User struct {
1361 ID string
1362 Login string
1363 Name string
1364 TypeName string `graphql:"__typename"`
1365 } `graphql:"... on User"`
1366 Bot struct {
1367 ID string
1368 Login string
1369 TypeName string `graphql:"__typename"`
1370 } `graphql:"... on Bot"`
1371 }
1372 } `graphql:"suggestedActors(first: 10, query: $query, capabilities: CAN_BE_ASSIGNED)"`
1373 } `graphql:"repository(owner: $owner, name: $name)"`
1374 }
1375
1376 var q *githubv4.String
1377 if query != "" {
1378 v := githubv4.String(query)
1379 q = &v
1380 }
1381
1382 variables := map[string]interface{}{
1383 "owner": githubv4.String(repo.RepoOwner()),
1384 "name": githubv4.String(repo.RepoName()),
1385 "query": q,
1386 }
1387
1388 var result responseData
1389 if err := client.Query(repo.RepoHost(), "SearchRepoAssignableActors", &result, variables); err != nil {
1390 return nil, 0, err
1391 }
1392
1393 var actors []AssignableActor
1394 for _, node := range result.Repository.SuggestedActors.Nodes {
1395 if node.User.TypeName == "User" {
1396 actors = append(actors, AssignableUser{
1397 id: node.User.ID,
1398 login: node.User.Login,
1399 name: node.User.Name,
1400 })
1401 } else if node.Bot.TypeName == "Bot" {
1402 actors = append(actors, AssignableBot{
1403 id: node.Bot.ID,
1404 login: node.Bot.Login,
1405 })
1406 }
1407 }
1408
1409 return actors, result.Repository.AssignableUsers.TotalCount, nil

Callers 1

RepoAssigneeSearchFuncFunction · 0.92

Calls 5

StringMethod · 0.65
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
QueryMethod · 0.65
RepoHostMethod · 0.65

Tested by

no test coverage detected