Commit cc59434ed543

Vincent Demeester <vincent@sbr.pm>
2026-03-27 10:05:56
feat(daily-plan): add reviews given to weekly report
Added FetchReviewsGivenSince to pull PRs reviewed by the user from GitHub, filtered to exclude own PRs. Weekly command now shows a dedicated reviews given section for retrospectives and manager-facing reports.
1 parent 07cce8a
Changed files (2)
tools
daily-plan
cmd
daily-plan
internal
tools/daily-plan/cmd/daily-plan/main.go
@@ -433,6 +433,7 @@ type jsonWeekly struct {
 	NextMonday     string     `json:"next_monday"`
 	JiraCompleted  []jsonJira `json:"jira_completed"`
 	GHMerged       []jsonGH   `json:"github_merged"`
+	GHReviewed     []jsonGH   `json:"github_reviewed"`
 	JiraInProgress []jsonJira `json:"jira_in_progress"`
 	JiraBacklog    []jsonJira `json:"jira_backlog"`
 	GHIssues       []jsonGH   `json:"github_issues"`
@@ -447,6 +448,7 @@ func cmdWeekly(ctx context.Context, cfg *config.Config) error {
 
 	completed, _ := jira.FetchCompletedSince(ctx, cfg.Jira.User, monday)
 	merged, _ := github.FetchMergedPRsSince(ctx, cfg.GitHub.Username, monday, cfg.GitHub.Owners)
+	reviewed, _ := github.FetchReviewsGivenSince(ctx, cfg.GitHub.Username, monday, cfg.GitHub.Owners)
 	inprog, _ := jira.FetchByStatus(ctx, cfg.Jira.User, []string{"In Progress", "Code Review", "On QA"})
 	todo, _ := jira.FetchByStatus(ctx, cfg.Jira.User, []string{"To Do", "New"})
 	ghIssues, _ := github.FetchAssignedIssues(ctx, cfg.GitHub.Username, cfg.GitHub.Owners)
@@ -457,6 +459,7 @@ func cmdWeekly(ctx context.Context, cfg *config.Config) error {
 			NextMonday:     nextMonday.Format("2006-01-02"),
 			JiraCompleted:  jiraToJSON(completed, cfg.Jira.BaseURL),
 			GHMerged:       ghToJSON(merged),
+			GHReviewed:     ghToJSON(reviewed),
 			JiraInProgress: jiraToJSON(inprog, cfg.Jira.BaseURL),
 			JiraBacklog:    jiraToJSON(todo, cfg.Jira.BaseURL),
 			GHIssues:       ghToJSON(ghIssues),
@@ -471,6 +474,9 @@ func cmdWeekly(ctx context.Context, cfg *config.Config) error {
 	display.SubHeader("Completed This Week (GitHub — Merged PRs)")
 	display.GitHubItems(merged, "done")
 
+	display.SubHeader("Reviews Given This Week (GitHub)")
+	display.GitHubItems(reviewed, "review")
+
 	display.SubHeader("Still In Progress (Jira)")
 	display.JiraIssues(inprog, "active")
 
tools/daily-plan/internal/github/github.go
@@ -127,6 +127,30 @@ func FetchMergedPRsSince(ctx context.Context, username string, since time.Time,
 	return runGHSearch(ctx, args, "pr")
 }
 
+// FetchReviewsGivenSince fetches PRs reviewed by the user since a given date.
+func FetchReviewsGivenSince(ctx context.Context, username string, since time.Time, owners []string) ([]Item, error) {
+	args := []string{
+		"search", "prs",
+		"--reviewed-by", username,
+		"--updated", fmt.Sprintf(">=%s", since.Format("2006-01-02")),
+		"--limit", "30",
+		"--json", "repository,number,title,author,createdAt,closedAt",
+	}
+	args = append(args, ownerFlags(owners)...)
+	items, err := runGHSearch(ctx, args, "pr")
+	if err != nil {
+		return nil, err
+	}
+	// Filter out own PRs (already shown in merged section)
+	var reviews []Item
+	for _, item := range items {
+		if item.Author != username {
+			reviews = append(reviews, item)
+		}
+	}
+	return reviews, nil
+}
+
 // FetchIssueSummary fetches title for a single GitHub issue.
 func FetchIssueSummary(ctx context.Context, repo string, number int) (string, error) {
 	cmd := exec.CommandContext(ctx, "gh", "issue", "view",