Skip to content

feat: Add support for stargazer count and history - #4611

Open
ninadsutrave wants to merge 2 commits into
google:masterfrom
ninadsutrave:feat/stargazer-count-history
Open

ninadsutrave wants to merge 2 commits into
google:masterfrom
ninadsutrave:feat/stargazer-count-history

Conversation

@ninadsutrave

Copy link
Copy Markdown

Fixes #4610

Adds the stargazer count and star history endpoints to ActivityService, next to the existing ListStargazers in activity_star.go:

  • GetStargazerCount (GET /repos/{owner}/{repo}/stargazers/count)
  • ListStargazerHistory (GET /repos/{owner}/{repo}/stargazers/history)

StargazerHistory.Week uses Timestamp, since the API returns it as a Unix timestamp, same as WeeklyCommitActivity. Accessors and the ListStargazerHistoryIter iterator are generated.

I used an AI assistant while working on this, and I've reviewed and tested the code myself.

@google-cla

google-cla Bot commented Oct 11, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@codecov

codecov Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.62%. Comparing base (e754d2c) to head (628a2f5).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4611   +/-   ##
=======================================
  Coverage   98.61%   98.62%           
=======================================
  Files         199      199           
  Lines       18693    18729   +36     
=======================================
+ Hits        18435    18471   +36     
  Misses        258      258           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmlewis

gmlewis commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator

Closing and reopening to kickstart the Google CLA check.

@ninadsutrave

Copy link
Copy Markdown
Author

@gmlewis thanks for kicking it earlier. I've signed the CLA now, but cla/google has been stuck in progress since I reopened the PR. Could you re-run it when you get a chance?

@gmlewis

gmlewis commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

@gmlewis thanks for kicking it earlier. I've signed the CLA now, but cla/google has been stuck in progress since I reopened the PR. Could you re-run it when you get a chance?

Unfortunately, it looks like it is having some problems right now. My kicking it didn't seem to help any. ☹️

@ninadsutrave

Copy link
Copy Markdown
Author

@gmlewis the CLA check passes now after a push. Thanks for looking into it earlier!

@gmlewis gmlewis added NeedsReview PR is awaiting a review before merging. and removed waiting for signed CLA labels Oct 13, 2026

@gmlewis gmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @ninadsutrave!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.

cc: @stevehipwell - @Not-Dhananjay-Mishra

Comment on lines +366 to +394

func TestStargazerCount_Marshal(t *testing.T) {
t.Parallel()
testJSONMarshal(t, &StargazerCount{}, `{"count":0}`)

u := &StargazerCount{Count: 42}

want := `{"count":42}`

testJSONMarshal(t, u, want)
}

func TestStargazerHistory_Marshal(t *testing.T) {
t.Parallel()

u := &StargazerHistory{
Days: []int{0, 12, 7, 0, 0, 0, 0},
Total: 19,
Week: referenceTimestamp,
}

want := `{
"days": [0, 12, 7, 0, 0, 0, 0],
"total": 19,
"week": ` + referenceTimeStr + `
}`

testJSONMarshal(t, u, want)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only write _Marshal tests for structs that implement custom Unmarshal/Marshal logic.
#4253 (comment)

Suggested change
func TestStargazerCount_Marshal(t *testing.T) {
t.Parallel()
testJSONMarshal(t, &StargazerCount{}, `{"count":0}`)
u := &StargazerCount{Count: 42}
want := `{"count":42}`
testJSONMarshal(t, u, want)
}
func TestStargazerHistory_Marshal(t *testing.T) {
t.Parallel()
u := &StargazerHistory{
Days: []int{0, 12, 7, 0, 0, 0, 0},
Total: 19,
Week: referenceTimestamp,
}
want := `{
"days": [0, 12, 7, 0, 0, 0, 0],
"total": 19,
"week": ` + referenceTimeStr + `
}`
testJSONMarshal(t, u, want)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NeedsReview PR is awaiting a review before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for stargazer count and history endpoints

3 participants