auto-update-daily-20260202
1// Package activity defines the core types for activity tracking.
2package activity
3
4import "time"
5
6// Category represents the source category of an activity.
7type Category string
8
9const (
10 CategoryGitHub Category = "github"
11 CategoryOrg Category = "org"
12 CategoryJira Category = "jira"
13 CategoryClaude Category = "claude"
14)
15
16// ActivityItem represents a single unit of work or event.
17type ActivityItem struct {
18 ID string `json:"id"`
19 Title string `json:"title"`
20 Description string `json:"description,omitempty"`
21 Category Category `json:"category"`
22 Type string `json:"type"` // e.g., "pr_merged", "todo_done", "issue_updated", "session"
23 Timestamp time.Time `json:"timestamp"`
24 URL string `json:"url,omitempty"`
25 Metadata map[string]string `json:"metadata,omitempty"`
26}
27
28// Activity aggregates items from a single source.
29type Activity struct {
30 Source string `json:"source"`
31 Items []ActivityItem `json:"items"`
32 Error string `json:"error,omitempty"`
33}
34
35// TimeRange represents the query period.
36type TimeRange struct {
37 Start time.Time `json:"start"`
38 End time.Time `json:"end"`
39 Description string `json:"description"` // e.g., "last week"
40}
41
42// Summary provides high-level metrics.
43type Summary struct {
44 TotalItems int `json:"total_items"`
45 ItemsByCategory map[string]int `json:"items_by_category"`
46 ItemsByType map[string]int `json:"items_by_type"`
47}
48
49// ReviewReport is the complete output.
50type ReviewReport struct {
51 GeneratedAt time.Time `json:"generated_at"`
52 TimeRange TimeRange `json:"time_range"`
53 Activities map[string]*Activity `json:"activities"`
54 Summary *Summary `json:"summary,omitempty"`
55}
56
57// CalculateSummary computes summary statistics from activities.
58func (r *ReviewReport) CalculateSummary() {
59 summary := &Summary{
60 ItemsByCategory: make(map[string]int),
61 ItemsByType: make(map[string]int),
62 }
63
64 for _, act := range r.Activities {
65 for _, item := range act.Items {
66 summary.TotalItems++
67 summary.ItemsByCategory[string(item.Category)]++
68 summary.ItemsByType[item.Type]++
69 }
70 }
71
72 r.Summary = summary
73}