leader

package
v0.0.0-...-89c2124 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package leader produces a leaderboard summary from a github repository's pull requests as a JSON file. This file can be loaded by the react frontend to display the summary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

type Author struct {
	Login     string `json:"login"`
	URL       string `json:"url"`
	AvatarURL string `json:"avatarUrl"`
}

Author represents GitHub user who authored PR, Review, etc.

type Chart

type Chart struct {
	Title      string  `json:"title"`
	MaxCount   int     `json:"maxCount"`
	TotalCount int     `json:"totalCount"`
	Points     []Point `json:"points"`
}

Chart contains data points, aggregated and meta data for charting.

type ChartData

type ChartData struct {
	ID              string            `json:"id"`
	Authors         map[string]Author `json:"authors"` // keyed by author.login (github username)
	Charts          []Chart           `json:"charts"`
	BotCommentCount int               `json:"botComments"`
	Config          ChartDataConfig   `json:"config"`
}

ChartData holds all aggregate PR, review and comment data relevant to visualisation.

func ChartDataFromPRs

func ChartDataFromPRs(gqlPRs []PRNode, config ChartDataConfig) ChartData

ChartDataFromPRs creates relevant struct for visualising aggregated PR, review and comment data. Input to this function is PR data as returned by GitHub API v4 (GraphQL).

type ChartDataConfig

type ChartDataConfig struct {
	LabelRegexp  *regexp.Regexp `json:"-"`
	LabelGlob    string         `json:"labelGlob"`
	BotName      string         `json:"botName"`
	CreatedAfter time.Time      `json:"createdAfter"`
	Repository   Repository     `json:"repository"`
}

ChartDataConfig contains filters, constants and meta data for aggregating chartable data from PRs

type Configuration

type Configuration struct {
	ChartConfig ChartDataConfig
	QueryConfig QueryConfig
}

Configuration holds configuration for retrieving data via GitHub API (query) and building aggregated Chart Data

func Config

func Config() (Configuration, error)

Config returns configuration for retrieving data via GitHub API (query) and building aggregated Chart Data

type Label

type Label struct {
	Name string `json:"name"`
}

Label represents GitHub label as used on Issues and PRs.

type PRNode

type PRNode struct {
	Number    int       `json:"number"`
	URL       string    `json:"url"`
	State     string    `json:"state"`
	Title     string    `json:"title"`
	Author    Author    `json:"author"`
	CreatedAt time.Time `json:"createdAt"`
	Reviews   struct {
		ReviewNodes []Review `json:"nodes"`
	} `json:"reviews"`
	Labels struct {
		LabelNodes []Label `json:"nodes"`
	} `json:"labels"`
}

PRNode represents a GraphQL response node for a PR (Pull Request) It contains in all labels and reviews for the PR. Reviews contain authors and the total count of comments.

func QueryAPI

func QueryAPI(config QueryConfig) ([]PRNode, error)

QueryAPI requests PR data from GitHub API v4 (GraphQL). Responses can hold a maximum of 100 PRs due to GitHub rate limiting. If there are more than 100 PRs subsequent queries issued recursively will request the following "pages" of data starting at the "cursor" value. All PR data is aggregated into one data structure and returned as slice of PRNode

type Point

type Point struct {
	Author string `json:"author"`
	Count  int    `json:"count"`
}

Point contains chartable data point per for a GitHub user. Count may represent total number of Pull Requests merged, merged or open, reviews, comments etc. per user.

type QueryConfig

type QueryConfig struct {
	Token        string
	Cursor       string
	QueryPattern string
	Client       *http.Client
	Repository   Repository
}

QueryConfig contains values for building the GitHub GraphQL query to retrieve PRs, as well as, http client and auth token to by used

type Repository

type Repository struct {
	Name  string `json:"name"`
	Owner string `json:"owner"`
	URL   string `json:"url"`
}

Repository meta data used in ChartData

type Review

type Review struct {
	Author   Author `json:"author"`
	Comments struct {
		TotalCount int `json:"totalCount"`
	} `json:"comments"`
}

Review represents GitHub Pull Request Review, details are omitted.

Jump to

Keyboard shortcuts

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