MCPcopy
hub / github.com/cli/cli / ProjectItems

Method ProjectItems

pkg/cmd/project/shared/queries/queries.go:658–721  ·  view source on GitHub ↗

ProjectItems returns the items of a project. If the OwnerType is VIEWER, no login is required. If limit is 0, the default limit is used. The queryStr parameter is passed as a server-side filter to the items connection, using the same syntax as the GitHub Projects filter bar (e.g. "assignee:octocat",

(o *Owner, number int32, limit int, queryStr string)

Source from the content-addressed store, hash-verified

656// filter to the items connection, using the same syntax as the GitHub Projects filter bar
657// (e.g. "assignee:octocat", "status:done").
658func (c *Client) ProjectItems(o *Owner, number int32, limit int, queryStr string) (*Project, error) {
659 project := &Project{}
660 if limit == 0 {
661 limit = LimitDefault
662 }
663
664 // set first to the min of limit and LimitMax
665 first := LimitMax
666 if limit < first {
667 first = limit
668 }
669
670 variables := map[string]interface{}{
671 "firstItems": githubv4.Int(first),
672 "afterItems": (*githubv4.String)(nil),
673 "firstFields": githubv4.Int(LimitMax),
674 "afterFields": (*githubv4.String)(nil),
675 "number": githubv4.Int(number),
676 }
677 if queryStr != "" {
678 variables["query"] = githubv4.String(queryStr)
679 }
680
681 var query pager[ProjectItem]
682 var queryName string
683 switch o.Type {
684 case UserOwner:
685 variables["login"] = githubv4.String(o.Login)
686 if queryStr == "" {
687 query = &userOwnerWithItemsNoQuery{}
688 } else {
689 query = &userOwnerWithItems{}
690 }
691 queryName = "UserProjectWithItems"
692 case OrgOwner:
693 variables["login"] = githubv4.String(o.Login)
694 if queryStr == "" {
695 query = &orgOwnerWithItemsNoQuery{}
696 } else {
697 query = &orgOwnerWithItems{}
698 }
699 queryName = "OrgProjectWithItems"
700 case ViewerOwner:
701 if queryStr == "" {
702 query = &viewerOwnerWithItemsNoQuery{}
703 } else {
704 query = &viewerOwnerWithItems{}
705 }
706 queryName = "ViewerProjectWithItems"
707 }
708 err := c.doQueryWithProgressIndicator(queryName, query, variables)
709 if err != nil {
710 return project, err
711 }
712 project = query.Project()
713
714 items, err := paginateAttributes(c, query, variables, queryName, "firstItems", "afterItems", limit, query.Nodes())
715 if err != nil {

Calls 5

paginateAttributesFunction · 0.85
ProjectMethod · 0.65
NodesMethod · 0.65
StringMethod · 0.45