Repository navigation
feat: Add support for stargazer count and history - #4611
ninadsutrave wants to merge 2 commits into
Conversation
|
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
|
Closing and reopening to kickstart the Google CLA check. |
|
@gmlewis thanks for kicking it earlier. I've signed the CLA now, but |
Unfortunately, it looks like it is having some problems right now. My kicking it didn't seem to help any. |
|
@gmlewis the CLA check passes now after a push. Thanks for looking into it earlier! |
gmlewis
left a comment
There was a problem hiding this comment.
Thank you, @ninadsutrave!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
|
|
||
| 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) | ||
| } |
There was a problem hiding this comment.
We only write _Marshal tests for structs that implement custom Unmarshal/Marshal logic.
#4253 (comment)
| 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) | |
| } |
Fixes #4610
Adds the stargazer count and star history endpoints to
ActivityService, next to the existingListStargazersinactivity_star.go:GetStargazerCount(GET /repos/{owner}/{repo}/stargazers/count)ListStargazerHistory(GET /repos/{owner}/{repo}/stargazers/history)StargazerHistory.WeekusesTimestamp, since the API returns it as a Unix timestamp, same asWeeklyCommitActivity. Accessors and theListStargazerHistoryIteriterator are generated.I used an AI assistant while working on this, and I've reviewed and tested the code myself.