hubbub

package
v1.0.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

hubbub provides an advanced in-memory search for GitHub using state machines

Index

Constants

View Source
const Issue = "issue"

Issue is a type representing an issue

View Source
const PullRequest = "pull_request"

PullRequest is a type representing a PR

Variables

This section is empty.

Functions

This section is empty.

Types

type CommentLike

type CommentLike interface {
	GetAuthorAssociation() string
	GetBody() string
	GetCreatedAt() time.Time
	GetReactions() *github.Reactions
	GetHTMLURL() string
	GetID() int64
	GetURL() string
	GetUpdatedAt() time.Time
	GetUser() *github.User
	String() string
}

type Config

type Config struct {
	Client *github.Client // Client is a GitHub client
	Cache  persist.Cacher // Cacher is a cache interface
	Repos  []string       // Repos is the repositories to search

	// Cache expiration times
	MemberRefresh time.Duration

	// MinSimilarity is how close two items need to be to each other to be called similar
	MinSimilarity float64

	// DebugNumber is used when you want to debug why a single item is being handled in a certain wait
	DebugNumber int
}

Config is how to configure a new hubbub engine

type Conversation

type Conversation struct {
	ID int `json:"id"`

	Organization string `json:"organization"`
	Project      string `json:"project"`

	Hidden  bool         `json:"hidden"`
	URL     string       `json:"url"`
	Title   string       `json:"title"`
	Author  *github.User `json:"author"`
	Type    string       `json:"type"`
	State   string       `json:"state"`
	Created time.Time    `json:"created"`

	// Latest comment or event
	Updated time.Time `json:"updated"`

	SelfInflicted bool `json:"self_inflicted"`

	Mergeable bool `json:"mergeable"`

	LatestAuthorResponse time.Time     `json:"latest_author_response"`
	LatestMemberResponse time.Time     `json:"latest_member_response"`
	AccumulatedHoldTime  time.Duration `json:"accumulated_hold_time"`
	CurrentHoldTime      time.Duration `json:"current_hold_time"`

	Assignees []*github.User  `json:"assignees"`
	Labels    []*github.Label `json:"labels"`

	ReactionsTotal    int            `json:"reactions_total"`
	Reactions         map[string]int `json:"reactions"`
	ReactionsPerMonth float64        `json:"reactions_per_month"`

	Commenters         []*github.User `json:"commenters"`
	LastCommentBody    string         `json:"last_comment_body"`
	LastCommentAuthor  *github.User   `json:"last_comment_author"`
	CommentsTotal      int            `json:"comments_total"`
	CommentersTotal    int            `json:"commenters_total"`
	CommentersPerMonth float64        `json:"commenters_per_month"`

	ClosedCommentsTotal   int          `json:"closed_comments_total"`
	ClosedCommentersTotal int          `json:"closed_commenters_total"`
	ClosedAt              time.Time    `json:"closed_at"`
	ClosedBy              *github.User `json:"closed_by"`

	Tags []Tag `json:"tags"`

	// Similar issues to this one
	Similar []*RelatedConversation `json:"similar"`

	Milestone string `json:"milestone"`
}

Conversation represents a discussion within a GitHub item (issue or PR)

type Engine

type Engine struct {

	// Must be settable from config
	MinSimilarity float64
	// contains filtered or unexported fields
}

Engine is the search engine interface for hubbub

func New

func New(cfg Config) *Engine

func (*Engine) FindSimilar

func (h *Engine) FindSimilar(co *Conversation) []*RelatedConversation

func (*Engine) IssueSummary

func (h *Engine) IssueSummary(i *github.Issue, cs []*github.IssueComment, authorIsMember bool) *Conversation

func (*Engine) PRSummary

func (h *Engine) PRSummary(pr *github.PullRequest, cs []*github.PullRequestComment) *Conversation

func (*Engine) SearchAny

func (h *Engine) SearchAny(ctx context.Context, org string, project string, fs []Filter, newerThan time.Time) ([]*Conversation, time.Time, error)

Search for GitHub issues or PR's

func (*Engine) SearchIssues

func (h *Engine) SearchIssues(ctx context.Context, org string, project string, fs []Filter, newerThan time.Time) ([]*Conversation, time.Time, error)

Search for GitHub issues or PR's

func (*Engine) SearchPullRequests

func (h *Engine) SearchPullRequests(ctx context.Context, org string, project string, fs []Filter, newerThan time.Time) ([]*Conversation, time.Time, error)

type Filter

type Filter struct {
	RawLabel string `yaml:"label,omitempty"`

	RawTag string `yaml:"tag,omitempty"`

	RawTitle string `yaml:"title,omitempty"`

	Milestone string `yaml:"milestone,omitempty"`

	Created            string `yaml:"created,omitempty"`
	Updated            string `yaml:"updated,omitempty"`
	Responded          string `yaml:"responded,omitempty"`
	Reactions          string `yaml:"reactions,omitempty"`
	ReactionsPerMonth  string `yaml:"reactions-per-month,omitempty"`
	Comments           string `yaml:"comments,omitempty"`
	Commenters         string `yaml:"commenters,omitempty"`
	CommentersPerMonth string `yaml:"commenters-per-month,omitempty"`
	ClosedComments     string `yaml:"comments-while-closed,omitempty"`
	ClosedCommenters   string `yaml:"commenters-while-closed,omitempty"`
	State              string `yaml:"state,omitempty"`
	// contains filtered or unexported fields
}

Filter lets you do less.

func (*Filter) LabelNegate

func (f *Filter) LabelNegate() bool

func (*Filter) LabelRegex

func (f *Filter) LabelRegex() *regexp.Regexp

func (*Filter) LoadLabelRegex

func (f *Filter) LoadLabelRegex() error

LoadLabelRegex loads a new label reegx

func (*Filter) LoadTagRegex

func (f *Filter) LoadTagRegex() error

LoadTagRegex loads a new tag regex

func (*Filter) LoadTitleRegex

func (f *Filter) LoadTitleRegex() error

LoadTitleRegex loads a new title regex

func (*Filter) TagNegate

func (f *Filter) TagNegate() bool

func (*Filter) TagRegex

func (f *Filter) TagRegex() *regexp.Regexp

func (*Filter) TitleNegate

func (f *Filter) TitleNegate() bool

func (*Filter) TitleRegex

func (f *Filter) TitleRegex() *regexp.Regexp

type GitHubItem

type GitHubItem interface {
	GetAssignee() *github.User
	GetBody() string
	GetComments() int
	GetHTMLURL() string
	GetCreatedAt() time.Time
	GetID() int64
	GetMilestone() *github.Milestone
	GetNumber() int
	GetClosedAt() time.Time
	GetState() string
	GetTitle() string
	GetURL() string
	GetUpdatedAt() time.Time
	GetUser() *github.User
	String() string
}

GitHubItem is an interface that matches both GitHub Issues and PullRequests

type RelatedConversation

type RelatedConversation struct {
	Organization string `json:"org"`
	Project      string `json:"project"`
	ID           int    `json:"int"`

	URL     string       `json:"url"`
	Title   string       `json:"title"`
	Author  *github.User `json:"author"`
	Type    string       `json:"type"`
	Created time.Time    `json:"created"`
}

A subset of Conversation for related items (requires less memory than a Conversation)

type Tag

type Tag struct {
	ID          string `json:"id"`
	Description string `json:"description"`
}

Tag is used for automatically labelling issues

Jump to

Keyboard shortcuts

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