@@ -50,7 +50,7 @@ var recentReposQuery struct {
5050 Node qlRepository
5151 }
5252 } `graphql:"repositories(first: $count, privacy: PUBLIC, isFork: $isFork, ownerAffiliations: OWNER, orderBy: {field: CREATED_AT, direction: DESC})"`
53- } `graphql:"user (login:$username )"`
53+ } `graphql:"repositoryOwner (login: $owner )"`
5454}
5555
5656var recentReleasesQuery struct {
@@ -155,8 +155,6 @@ var repoRecentReleasesQuery struct {
155155}
156156
157157func recentContributions (count int ) []Contribution {
158- // fmt.Printf("Finding recent contributions...\n")
159-
160158 var contributions []Contribution
161159 variables := map [string ]interface {}{
162160 "username" : githubv4 .String (username ),
@@ -187,16 +185,13 @@ func recentContributions(count int) []Contribution {
187185 return contributions [i ].OccurredAt .After (contributions [j ].OccurredAt )
188186 })
189187
190- // fmt.Printf("Found %d contributions!\n", len(repos))
191188 if len (contributions ) > count {
192189 return contributions [:count ]
193190 }
194191 return contributions
195192}
196193
197194func recentPullRequests (count int ) []PullRequest {
198- // fmt.Printf("Finding recently created pullRequests...\n")
199-
200195 var pullRequests []PullRequest
201196 variables := map [string ]interface {}{
202197 "username" : githubv4 .String (username ),
@@ -222,18 +217,15 @@ func recentPullRequests(count int) []PullRequest {
222217 }
223218 }
224219
225- // fmt.Printf("Found %d pullRequests!\n", len(pullRequests))
226220 return pullRequests
227221}
228222
229- func recentRepos (count int ) []Repo {
230- // fmt.Printf("Finding recently created repos...\n")
231-
223+ func recentCreatedRepos (owner string , count int ) []Repo {
232224 var repos []Repo
233225 variables := map [string ]interface {}{
234- "username " : githubv4 .String (username ),
235- "count" : githubv4 .Int (count + 1 ), // +1 in case we encounter the meta-repo itself
236- "isFork" : githubv4 .Boolean (false ),
226+ "owner " : githubv4 .String (owner ),
227+ "count" : githubv4 .Int (count + 1 ), // +1 in case we encounter the meta-repo itself
228+ "isFork" : githubv4 .Boolean (false ),
237229 }
238230 err := gitHubClient .Query (context .Background (), & recentReposQuery , variables )
239231 if err != nil {
@@ -242,7 +234,7 @@ func recentRepos(count int) []Repo {
242234
243235 for _ , v := range recentReposQuery .User .Repositories .Edges {
244236 // ignore meta-repo
245- if string (v .Node .NameWithOwner ) == fmt .Sprintf ("%s/%s" , username , username ) {
237+ if string (v .Node .NameWithOwner ) == fmt .Sprintf ("%s/%s" , owner , owner ) {
246238 continue
247239 }
248240
@@ -252,18 +244,15 @@ func recentRepos(count int) []Repo {
252244 }
253245 }
254246
255- // fmt.Printf("Found %d repos!\n", len(repos))
256247 return repos
257248}
258249
259- func recentForks (count int ) []Repo {
260- // fmt.Printf("Finding recently created repos...\n")
261-
250+ func recentForkedRepos (owner string , count int ) []Repo {
262251 var repos []Repo
263252 variables := map [string ]interface {}{
264- "username " : githubv4 .String (username ),
265- "count" : githubv4 .Int (count + 1 ), // +1 in case we encounter the meta-repo itself
266- "isFork" : githubv4 .Boolean (true ),
253+ "owner " : githubv4 .String (owner ),
254+ "count" : githubv4 .Int (count + 1 ), // +1 in case we encounter the meta-repo itself
255+ "isFork" : githubv4 .Boolean (true ),
267256 }
268257 err := gitHubClient .Query (context .Background (), & recentReposQuery , variables )
269258 if err != nil {
@@ -272,7 +261,7 @@ func recentForks(count int) []Repo {
272261
273262 for _ , v := range recentReposQuery .User .Repositories .Edges {
274263 // ignore meta-repo
275- if string (v .Node .NameWithOwner ) == fmt .Sprintf ("%s/%s" , username , username ) {
264+ if string (v .Node .NameWithOwner ) == fmt .Sprintf ("%s/%s" , owner , owner ) {
276265 continue
277266 }
278267
@@ -281,14 +270,10 @@ func recentForks(count int) []Repo {
281270 break
282271 }
283272 }
284-
285- // fmt.Printf("Found %d repos!\n", len(repos))
286273 return repos
287274}
288275
289276func recentReleases (count int ) []Repo {
290- // fmt.Printf("Finding recent releases...\n")
291-
292277 var after * githubv4.String
293278 var repos []Repo
294279
@@ -302,7 +287,6 @@ func recentReleases(count int) []Repo {
302287 panic (err )
303288 }
304289
305- // fmt.Printf("%+v\n", query)
306290 if len (recentReleasesQuery .User .RepositoriesContributedTo .Edges ) == 0 {
307291 break
308292 }
@@ -337,13 +321,62 @@ func recentReleases(count int) []Repo {
337321 return repos [i ].LastRelease .PublishedAt .After (repos [j ].LastRelease .PublishedAt )
338322 })
339323
340- // fmt.Printf("Found %d repos!\n", len(repos))
341324 if len (repos ) > count {
342325 return repos [:count ]
343326 }
344327 return repos
345328}
346329
330+ /*
331+ {
332+ repositoryOwner(login: "charmbracelet") {
333+ id
334+ login
335+ repositories(
336+ first: 5
337+ privacy: PUBLIC
338+ orderBy: {field: PUSHED_AT, direction: DESC}
339+ ) {
340+ edges {
341+ node {
342+ name
343+ description
344+ url
345+ }
346+ }
347+ }
348+ }
349+ }
350+ */
351+ func recentPushedRepos (owner string , count int ) []Repo {
352+ var query struct {
353+ Owner struct {
354+ Repositories struct {
355+ Edges []struct {
356+ Node qlRepository
357+ }
358+ } `graphql:"repositories(first: $count, privacy: PUBLIC, orderBy: {field: PUSHED_AT, direction: DESC})"`
359+ } `graphql:"repositoryOwner(login: $owner)"`
360+ }
361+ var repos []Repo
362+ variables := map [string ]interface {}{
363+ "count" : githubv4 .Int (count ),
364+ "owner" : githubv4 .String (owner ),
365+ }
366+ err := gitHubClient .Query (context .Background (), & query , variables )
367+ if err != nil {
368+ panic (err )
369+ }
370+
371+ for _ , v := range query .Owner .Repositories .Edges {
372+ repos = append (repos , repoFromQL (v .Node ))
373+ if len (repos ) == count {
374+ break
375+ }
376+ }
377+ return repos
378+ }
379+
347380func repo (owner , name string ) Repo {
348381 variables := map [string ]interface {}{
349382 "owner" : githubv4 .String (owner ),
0 commit comments