report

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package report defines the data model for reputation reports, including Author, Stats, Query, and Report types.

Index

Constants

This section is empty.

Variables

View Source
var ModelVersion = score.ModelVersion

ModelVersion is the current scoring model version.

Functions

func Round added in v0.2.0

func Round(num float64) int

Round rounds a float64 to the nearest integer.

func ToFixed added in v0.2.0

func ToFixed(num float64, precision int) float64

ToFixed truncates a float64 to the given precision.

Types

type Author

type Author struct {
	Username   string         `json:"username"`
	Reputation float64        `json:"reputation"`
	Context    *AuthorContext `json:"context,omitempty"`
	Stats      *Stats         `json:"stats,omitempty"`
}

Author represents a commit author.

func MakeAuthor

func MakeAuthor(username string) *Author

MakeAuthor creates a new Author instance.

func (*Author) String

func (a *Author) String() string

type AuthorContext added in v0.2.0

type AuthorContext struct {
	Created string `json:"created,omitempty"`
	Name    string `json:"name,omitempty"`
	Email   string `json:"email,omitempty"`
	Company string `json:"company,omitempty"`
}

AuthorContext holds optional author metadata.

type CategoryWeight added in v0.4.0

type CategoryWeight = score.CategoryWeight

CategoryWeight describes a scoring category and its weight.

type Meta added in v0.4.0

type Meta struct {
	ModelVersion string           `json:"model_version"`
	Categories   []CategoryWeight `json:"categories"`
}

Meta holds scoring model metadata.

type Query added in v0.1.0

type Query struct {
	// Repo is the repo to query (required).
	Repo string
	// Commit is the commit to query (optional).
	Commit string
	// Stats includes stats in the output (optional).
	Stats bool

	// Kind is the kind of repo (e.g. github.com, gitlab.com, etc.).
	// Will be parsed from Repo.
	Kind string

	// Owner is the owner of the repo.
	// Will be parsed from Repo.
	Owner string

	// Name is the name of the repo.
	// Will be parsed from Repo.
	Name string
}

Query is a query for a repo and commit.

func MakeQuery added in v0.1.0

func MakeQuery(repo, commit string, stats bool) (*Query, error)

MakeQuery returns a new query for the given repo and commit.

func (*Query) String added in v0.1.0

func (q *Query) String() string

String returns a string representation of the query.

func (*Query) Validate added in v0.1.0

func (q *Query) Validate() error

Validate validates the query.

type Report

type Report struct {
	Repo              string    `json:"repo,omitempty"`
	AtCommit          string    `json:"at_commit,omitempty"`
	GeneratedOn       time.Time `json:"generated_on,omitempty"`
	TotalCommits      int64     `json:"total_commits,omitempty"`
	TotalContributors int64     `json:"total_contributors,omitempty"`
	Meta              *Meta     `json:"meta,omitempty"`
	Contributors      []*Author `json:"contributors,omitempty"`
}

Report is the top-level output for a reputation query.

func (*Report) SortAuthors added in v0.1.0

func (r *Report) SortAuthors()

SortAuthors sorts the authors by username.

type Stats added in v0.1.0

type Stats struct {
	Suspended         bool  `json:"suspended,omitempty"`
	CommitsVerified   bool  `json:"verified_commits,omitempty"`
	StrongAuth        bool  `json:"strong_auth,omitempty"`
	AgeDays           int64 `json:"age_days"`
	Commits           int64 `json:"commits"`
	UnverifiedCommits int64 `json:"unverified_commits"`
	PublicRepos       int64 `json:"public_repos,omitempty"`
	PrivateRepos      int64 `json:"private_repos,omitempty"`
	Followers         int64 `json:"followers,omitempty"`
	Following         int64 `json:"following,omitempty"`
	LastCommitDays    int64 `json:"last_commit_days,omitempty"`
	OrgMember         bool  `json:"org_member,omitempty"`
}

Stats represents a set of statistics for an author.

Jump to

Keyboard shortcuts

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