crawler

package
v0.0.0-...-cc6e33c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadAndUnzipArtifact

func DownloadAndUnzipArtifact(url url.URL) [][]byte

DownloadAndUnzipArtifact Download And Unzip Artifact by the url from FetchLatestArtifactUrl.

func FetchIssueWithCommentsByLabels

func FetchIssueWithCommentsByLabels(client ClientV4, owner, name string, labels []string, since githubv4.DateTime, count ...int) (*[]IssueWithComments, []error)

FetchIssueWithCommentsByLabels fetch issue combined with comments If there are empty in labels ,you will not get anything.

func FetchLatestArtifactUrl

func FetchLatestArtifactUrl(client *github.Client, owner, name string) *url.URL

FetchLatestArtifact fetch the latest artifact in the repo.

func InitGithubV4Client

func InitGithubV4Client(tokens []string)

initGithubV4Client init the clients pool.

func NewGithubClient

func NewGithubClient(token string) *github.Client

newGithubClient new clientv4 by github tokens.

func RefreshGithubV4Client

func RefreshGithubV4Client(tokens []string)

RefreshGithubV4Client just init client pool again

Types

type ClientV4

type ClientV4 struct {
	// contains filtered or unexported fields
}

The Client used for client pool

func NewGithubV4Client

func NewGithubV4Client() ClientV4

NewGithubV4Client return the first Client in the pool

func (ClientV4) QueryWithClientsPool

func (c ClientV4) QueryWithClientsPool(ctx context.Context, q interface{}, variables map[string]interface{}) error

QueryWithClientsPool package the client pool , you could use it just like client.Query in githubv4 package

type Comment

type Comment struct {
	DatabaseId     githubv4.Int
	Body           string
	ViewerCanReact bool
	Author         struct {
		Login     string
		AvatarURL string `graphql:"avatarUrl(size: 72)"`
	}
}

Comment define Comment fetched from github api v4

type Issue

type Issue struct {
	DatabaseId githubv4.Int
	Number     githubv4.Int
	Author     struct {
		Login     string
		AvatarURL string `graphql:"avatarUrl(size: 72)"`
	}
	Closed    githubv4.Boolean
	ClosedAt  githubv4.DateTime
	CreatedAt githubv4.DateTime
	Labels    struct {
		Nodes []struct {
			Name githubv4.String
		}
	} `graphql:"labels(first: 100)"`

	Assignees struct {
		Nodes []struct {
			Login githubv4.String
			Email githubv4.String
		}
	} `graphql:"assignees(first: 100)"`
	Title githubv4.String
	Body  githubv4.String

	TimelineItems struct {
		Nodes []struct {
			Typename             string `graphql:"__typename"`
			CrossReferencedEvent struct {
				Actor struct {
					Login githubv4.String
				}
				CreatedAt githubv4.DateTime
			} `graphql:"... on CrossReferencedEvent"`
			AssignedEvent struct {
				Actor struct {
					Login githubv4.String
				}
				Assignee struct {
					User struct {
						Login githubv4.String
						Email githubv4.String
					} `graphql:"... on User"`
				}
				CreatedAt githubv4.DateTime
			} `graphql:"... on AssignedEvent"`
			UnassignedEvent struct {
				Actor struct {
					Login githubv4.String
				}
				Assignee struct {
					User struct {
						Login githubv4.String
						Email githubv4.String
					} `graphql:"... on User"`
				}
				CreatedAt githubv4.DateTime
			} `graphql:"... on UnassignedEvent"`
		}
	} `graphql:"timelineItems(first: 100)"`
}

Issue define issue data fetched from github api v4

type IssueConnection

type IssueConnection struct {
	Nodes    []Issue
	PageInfo struct {
		EndCursor   githubv4.String
		HasNextPage bool
	}
}

IssueConnection define IssueConnection fetched from github api v4

type IssueWithComments

type IssueWithComments struct {
	Issue
	Comments *[]Comment
}

IssueWithComments define

type PageInfo

type PageInfo struct {
	EndCursor   githubv4.String
	HasNextPage bool
}

type Query

type Query interface {
	GetPageInfo() PageInfo
	GetQuery() Query
}

func FetchAllQueries

func FetchAllQueries(client ClientV4, q Query, variables map[string]interface{}) ([]Query, error)

FetchAllQueries just travel all the query among pages. You must input a Query pointer just like it used in fetchIssuesByLabelsStates : FetchAllQueries(client,&query,variables), because query of client need a pointer query input.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL