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

Method ProjectItems

pkg/cmd/project/shared/queries/queries.go:691–754  ·  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 := LimitMax
699 if limit < first {
700 first = limit
701 }
702
703 variables := map[string]interface{}{
704 "firstItems": githubv4.Int(first),
705 "afterItems": (*githubv4.String)(nil),
706 "firstFields": githubv4.Int(LimitMax),
707 "afterFields": (*githubv4.String)(nil),
708 "number": githubv4.Int(number),
709 }
710 if queryStr != "" {
711 variables["query"] = githubv4.String(queryStr)
712 }
713
714 var query pager[ProjectItem]
715 var queryName string
716 switch o.Type {
717 case UserOwner:
718 variables["login"] = githubv4.String(o.Login)
719 if queryStr == "" {
720 query = &userOwnerWithItemsNoQuery{}
721 } else {
722 query = &userOwnerWithItems{}
723 }
724 queryName = "UserProjectWithItems"
725 case OrgOwner:
726 variables["login"] = githubv4.String(o.Login)
727 if queryStr == "" {
728 query = &orgOwnerWithItemsNoQuery{}
729 } else {
730 query = &orgOwnerWithItems{}
731 }
732 queryName = "OrgProjectWithItems"
733 case ViewerOwner:
734 if queryStr == "" {
735 query = &viewerOwnerWithItemsNoQuery{}
736 } else {
737 query = &viewerOwnerWithItems{}
738 }
739 queryName = "ViewerProjectWithItems"
740 }
741 err := c.doQueryWithProgressIndicator(queryName, query, variables)
742 if err != nil {
743 return project, err
744 }
745 project = query.Project()
746
747 items, err := paginateAttributes(c, query, variables, queryName, "firstItems", "afterItems", limit, query.Nodes())
748 if err != nil {

Calls 5

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