query

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortedDays

func SortedDays(byDay map[string]*ActivityResult) []string

SortedDays returns the day keys from ByDay in chronological order.

Types

type ActivityMetadata

type ActivityMetadata struct {
	Since       time.Time `json:"since"`
	Until       time.Time `json:"until"`
	PRCount     int       `json:"pr_count"`
	IssueCount  int       `json:"issue_count"`
	CommitCount int       `json:"commit_count"`
}

ActivityMetadata records the query parameters and result counts.

type ActivityResult

type ActivityResult struct {
	PRClusters        []PRCluster        `json:"-"`
	StandaloneIssues  []StandaloneIssue  `json:"-"`
	StandaloneCommits []StandaloneCommit `json:"-"`
	Metadata          ActivityMetadata   `json:"-"`
}

ActivityResult contains assembled GitHub activity grouped by cluster type. Use MarshalEventClusters() to produce the flat JSON array for the extractor.

func AssembleActivity

func AssembleActivity(ctx context.Context, s *store.Store, since, until time.Time) (*ActivityResult, error)

AssembleActivity queries CodeDB for GitHub activity within the given time window and returns structured event clusters for the fact extractor.

func (*ActivityResult) ByDay

func (r *ActivityResult) ByDay() map[string]*ActivityResult

ByDay partitions the ActivityResult into per-day buckets keyed by YYYY-MM-DD. Primary timestamps: PRCluster uses MergedAt (if set) else UpdatedAt; StandaloneIssue uses UpdatedAt; StandaloneCommit uses Timestamp. Items with unparseable timestamps go into today's bucket.

func (*ActivityResult) MarshalEventClusters

func (r *ActivityResult) MarshalEventClusters() ([]byte, error)

MarshalEventClusters produces a flat JSON array of event clusters with type discriminators, matching the extractor input spec.

type Comment

type Comment struct {
	Author    string `json:"author"`
	Body      string `json:"body"`
	CreatedAt string `json:"created_at"`
}

Comment is a discussion comment (PR or issue).

type CommitEntry

type CommitEntry struct {
	SHA       string  `json:"sha"`
	Message   *string `json:"message"`
	Author    *string `json:"author"`
	Timestamp *string `json:"timestamp"`
}

CommitEntry is a commit linked to a PR or standalone. Fields may be nil when commit metadata is unavailable (squash/rebase).

type PRCluster

type PRCluster struct {
	Number             int           `json:"number"`
	Title              string        `json:"title"`
	Description        string        `json:"description"`
	Author             string        `json:"author"`
	Status             string        `json:"status"`
	MergedAt           *string       `json:"merged_at,omitempty"`
	UpdatedAt          *string       `json:"-"` // internal: for per-day bucketing
	URL                string        `json:"url"`
	Labels             []string      `json:"labels,omitempty"`
	Commits            []CommitEntry `json:"commits"`
	Reviews            []ReviewGroup `json:"reviews"`
	DiscussionComments []Comment     `json:"discussion_comments"`
}

PRCluster represents a pull request with its associated comments and commits.

type ReviewComment

type ReviewComment struct {
	Body string  `json:"body"`
	Path *string `json:"path"`
	Line *int    `json:"line"`
}

ReviewComment is a single code review comment with optional file location.

type ReviewGroup

type ReviewGroup struct {
	Reviewer string          `json:"reviewer"`
	Comments []ReviewComment `json:"comments"`
}

ReviewGroup groups review comments by reviewer.

type StandaloneCommit

type StandaloneCommit struct {
	SHA       string `json:"sha"`
	Message   string `json:"message"`
	Author    string `json:"author"`
	Timestamp string `json:"timestamp"`
}

StandaloneCommit is a commit not linked to any PR.

type StandaloneIssue

type StandaloneIssue struct {
	Number    int       `json:"number"`
	Title     string    `json:"title"`
	Body      string    `json:"body"`
	Author    string    `json:"author"`
	State     string    `json:"state"`
	UpdatedAt *string   `json:"-"` // internal: for per-day bucketing
	URL       string    `json:"url"`
	Comments  []Comment `json:"comments"`
}

StandaloneIssue is an issue not referenced by any PR in the window.

Jump to

Keyboard shortcuts

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