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

Method ProjectItems

pkg/cmd/project/shared/queries/queries.go:691–751  ·  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

689// filter to the items connection, using the same syntax as the GitHub Projects filter bar
690// (e.g. "assignee:octocat", "status:done").
691func (c *Client) ProjectItems(o *Owner, number int32, limit int, queryStr string) (*Project, error) {
692 project := &Project{}
693 if limit == 0 {
694 limit = LimitDefault
695 }
696
697 // set first to the min of limit and LimitMax
698 first := min(limit, LimitMax)
699
700 variables := map[string]any{
701 "firstItems": githubv4.Int(first),
702 "afterItems": (*githubv4.String)(nil),
703 "firstFields": githubv4.Int(LimitMax),
704 "afterFields": (*githubv4.String)(nil),
705 "number": githubv4.Int(number),
706 }
707 if queryStr != "" {
708 variables["query"] = githubv4.String(queryStr)
709 }
710
711 var query pager[ProjectItem]
712 var queryName string
713 switch o.Type {
714 case UserOwner:
715 variables["login"] = githubv4.String(o.Login)
716 if queryStr == "" {
717 query = &userOwnerWithItemsNoQuery{}
718 } else {
719 query = &userOwnerWithItems{}
720 }
721 queryName = "UserProjectWithItems"
722 case OrgOwner:
723 variables["login"] = githubv4.String(o.Login)
724 if queryStr == "" {
725 query = &orgOwnerWithItemsNoQuery{}
726 } else {
727 query = &orgOwnerWithItems{}
728 }
729 queryName = "OrgProjectWithItems"
730 case ViewerOwner:
731 if queryStr == "" {
732 query = &viewerOwnerWithItemsNoQuery{}
733 } else {
734 query = &viewerOwnerWithItems{}
735 }
736 queryName = "ViewerProjectWithItems"
737 }
738 err := c.doQueryWithProgressIndicator(queryName, query, variables)
739 if err != nil {
740 return project, err
741 }
742 project = query.Project()
743
744 items, err := paginateAttributes(c, query, variables, queryName, "firstItems", "afterItems", limit, query.Nodes())
745 if err != nil {
746 return project, err
747 }
748

Calls 5

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