Help us shape the future of Go! Take the 2026 Go Developer Survey

dailyreport

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package dailyreport contains the provider-independent daily report rules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GroupCommits

func GroupCommits(pushes []Push, accounts map[string]string, resolve func(string) (string, error)) (map[string][]AttributedCommit, error)

GroupCommits attributes complete push records and removes repeat pushes. An empty account from resolve denotes an email without a matching account.

func SaveConfig

func SaveConfig(path string, c Config) error

SaveConfig writes private configuration atomically with owner-only permissions.

func SendCard

func SendCard(ctx context.Context, client *http.Client, webhook, title, summary string) error

SendCard sends one person's summary to a Feishu custom bot webhook.

func ShouldReport

func ShouldReport(accountType string, commits int) bool

ShouldReport excludes service accounts and users without commits.

Types

type AttributedCommit

type AttributedCommit struct {
	RepositoryID int64  `json:"repository_id"`
	ID           string `json:"id"`
	Message      string `json:"message"`
}

AttributedCommit omits author email from the provider input.

type Commit

type Commit struct {
	ID          string
	AuthorEmail string
	Message     string
}

Commit contains the information needed to attribute and summarize a commit.

type Config

type Config struct {
	Schedule  Schedule          `json:"schedule"`
	BaseURL   string            `json:"base_url"`
	Model     string            `json:"model"`
	APIKey    string            `json:"api_key"`
	Webhook   string            `json:"webhook"`
	OmitStore bool              `json:"omit_store"`
	Accounts  map[string]string `json:"accounts"`
}

Config is private server state; it must not be returned to ordinary users.

func LoadConfig

func LoadConfig(path string) (Config, error)

LoadConfig reads an explicitly selected private configuration file.

func (Config) Validate

func (c Config) Validate() error

Validate rejects ambiguous classifications and invalid calendar entries.

type DeliveryStore

type DeliveryStore interface {
	Delivered(date, account string) (bool, error)
	MarkDelivered(date, account string) error
}

DeliveryStore records successfully delivered cards for a report date.

type FileDeliveryStore

type FileDeliveryStore struct{ Path string }

FileDeliveryStore persists successful deliveries outside the source tree.

func (FileDeliveryStore) Delivered

func (s FileDeliveryStore) Delivered(date, account string) (bool, error)

Delivered checks whether the card has already been acknowledged.

func (FileDeliveryStore) MarkDelivered

func (s FileDeliveryStore) MarkDelivered(date, account string) error

MarkDelivered atomically records an acknowledged card.

type Push

type Push struct {
	RepositoryID int64
	Total        int
	Commits      []Commit
}

Push contains commits from a single repository push.

type ResponsesClient

type ResponsesClient struct {
	HTTP    *http.Client
	BaseURL string
	APIKey  string
	Model   string
	// OmitStore is for providers that reject the OpenAI store parameter.
	OmitStore bool
}

ResponsesClient speaks the text subset of the OpenAI Responses API.

func (ResponsesClient) Summarize

func (c ResponsesClient) Summarize(ctx context.Context, input string) (string, error)

Summarize asks the configured provider to summarize one person's commits.

type RunResult

type RunResult struct {
	Sent    int
	Skipped int
	Failed  int
}

RunResult contains counts only; commit messages and credentials stay private.

func Run

func Run(ctx context.Context, date string, grouped map[string][]AttributedCommit, store DeliveryStore, summarize func(context.Context, string) (string, error), send func(context.Context, string, string) error) (RunResult, error)

Run delivers one card for each classified author with commits. Callers must serialize runs that share a delivery store.

type Schedule

type Schedule struct {
	Enabled       bool     `json:"enabled"`
	Time          string   `json:"time"`
	SkipHolidays  bool     `json:"skip_holidays"`
	Holidays      []string `json:"holidays"`
	Workdays      []string `json:"workdays"`
	CalendarYears []int    `json:"calendar_years"`
}

Schedule is evaluated in China Standard Time. Workdays override weekends.

func (Schedule) Due

func (s Schedule) Due(now time.Time) (bool, error)

Due reports whether an automatic report is due at the given instant.

Jump to

Keyboard shortcuts

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