summary

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package summary counts the pull requests opened, merged and closed over a window, from the open listings and from the pull requests it keeps in SQLite, which it brings up to date by reading what changed since its last read, and back to a window's start where the store does not reach it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileFor

func FileFor(dir string, scope pullrequests.Scope) string

FileFor is the store's file in dir for a scope: a name digested from its repos and owners, so two scopes never share rows, and an edit to the registry starts a file of its own.

func Sync

func Sync(ctx context.Context, store *Store, scope pullrequests.Scope, since, now time.Time) error

Sync brings the store up to now for a window starting at since. Where the store does not reach back to since, it reads every pull request last updated from since up to where it does. Then it reads every one updated since the last sync. Nothing is kept unless every search answered.

Types

type Coverage

type Coverage struct {
	From   time.Time `json:"from"`
	Synced time.Time `json:"synced"`
}

Coverage is how far the store reaches. It holds every pull request in the scope last updated at or after From, each as it stood at Synced or later, and so every one merged or closed since From.

type KindValues

type KindValues struct {
	All    *float64 `json:"all"`
	People *float64 `json:"people"`
	Bots   *float64 `json:"bots"`
}

KindValues is a measure over pull requests, whoever opened them, then by author kind, each null where no pull request of that kind gives one.

type Kinds

type Kinds struct {
	All    int `json:"all"`
	People int `json:"people"`
	Bots   int `json:"bots"`
}

Kinds is a count of pull requests, whoever opened them, then split by whether a person or an app did. One whose author is gone counts as a person's.

type MergeBucket

type MergeBucket struct {
	Label       string   `json:"label"`
	FromSeconds float64  `json:"from_seconds"`
	ToSeconds   *float64 `json:"to_seconds"`
	Merged      Kinds    `json:"merged"`
}

MergeBucket is the merges that took from FromSeconds up to ToSeconds to land, from opening, with no ToSeconds on the last.

type Numbers

type Numbers struct {
	Window string    `json:"window"`
	Since  time.Time `json:"since"`
	Until  time.Time `json:"until"`
	// Open is the pull requests open at Until, and Opened those opened within the window,
	// whether open or closed now.
	Open           Kinds `json:"open"`
	Opened         Kinds `json:"opened"`
	Merged         Kinds `json:"merged"`
	ClosedUnmerged Kinds `json:"closed_unmerged"`
	// The times to merge run from opening to merging, over the merges within the window.
	MedianSecondsToMerge KindValues `json:"median_seconds_to_merge"`
	P90SecondsToMerge    KindValues `json:"p90_seconds_to_merge"`
	// ReviewedByRound is the merges whose first review was a review round's, and
	// ReviewedByRoundShare that as a share of the merges, from 0 to 1.
	ReviewedByRound      Kinds      `json:"merged_reviewed_by_round"`
	ReviewedByRoundShare KindValues `json:"merged_reviewed_by_round_share"`
	// Repos is each repo with a merge within the window, the most merges first.
	Repos       []RepoMerges  `json:"repos"`
	TimeToMerge []MergeBucket `json:"time_to_merge"`
	// MergedPer is hour or day, the span each of MergedOver counts, and MergedOver runs from
	// the period holding Since to the one holding Until, a day starting at local midnight.
	MergedPer  string         `json:"merged_per"`
	MergedOver []PeriodMerges `json:"merged_over"`
	// OpenOver is the open pull requests at about openSamples instants from Since to Until, a
	// whole number of hours apart, and at Until.
	OpenOver []OpenAt `json:"open_over"`
}

Numbers is what the Summary tab and prs summary show for one window.

func Count

func Count(window Window, kept []pullrequests.HistoryRecord, open []pullrequests.PullRequest, loc *time.Location) Numbers

Count is the numbers for the window, from the merged and closed pull requests in kept and the open ones in open. Where both hold a pull request, the record updated last stands, as on the board. GitHub's open search still finds one for a while after it merges, with the record it read before the merge, and one reopened since the store read it is newer in open. A record in open counts only while it stands open. Days start at midnight in loc.

type OpenAt

type OpenAt struct {
	At   time.Time `json:"at"`
	Open Kinds     `json:"open"`
}

OpenAt is the pull requests open at At.

type PeriodMerges

type PeriodMerges struct {
	Start  time.Time `json:"start"`
	Merged Kinds     `json:"merged"`
}

PeriodMerges is the merges within the hour or the day starting at Start.

type RepoMerges

type RepoMerges struct {
	Slug   string `json:"slug"`
	Merged Kinds  `json:"merged"`
	// MedianSecondsToMerge is from opening to merging, across the repo's merges.
	MedianSecondsToMerge float64 `json:"median_seconds_to_merge"`
}

RepoMerges is one repo's merges within the window.

type Store

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

Store is the pull requests one scope's repos hold, and how far back and how lately they were read.

func Open

func Open(path string) (*Store, error)

Open opens the store at path, making its directory and tables where they are missing. An empty path keeps the store in memory, for a run with nowhere to cache it.

func (*Store) Close

func (s *Store) Close() error

Close closes the file.

func (*Store) Closed

func (s *Store) Closed(since time.Time) ([]pullrequests.HistoryRecord, error)

Closed is every pull request the store holds merged or closed at or after since, the newest first.

func (*Store) Coverage

func (s *Store) Coverage() (Coverage, bool, error)

Coverage is how far the store reaches, and false where nothing has been read into it.

func (*Store) Keep

func (s *Store) Keep(records []pullrequests.HistoryRecord, coverage Coverage) error

Keep writes each record over any row it had that was updated no later, and the coverage, as one transaction, so the coverage never claims a read whose rows did not land. A board and a prs summary can sync one file at once, so the coverage only widens: the earliest From and the latest Synced stand. Each read asks for every update since a From older than any sync's start, so the later sync read every change since the earlier one began.

func (*Store) Path

func (s *Store) Path() string

Path is the store's file, and empty for one kept in memory.

type Window

type Window struct {
	Name         string
	Since, Until time.Time
}

Window is the stretch the numbers count, from Since up to Until. Name is how it was given, such as 30d.

Jump to

Keyboard shortcuts

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