Commit fe76645
Changed files (4)
badges
star-gazer
src
task
badges/star-gazer/self-star.png
Binary file
badges/star-gazer/star-gazer.ts
@@ -2,12 +2,24 @@ import { define } from '#src'
export default define({
url: import.meta.url,
- badges: ['star-gazer'] as const,
+ badges: ['star-gazer', 'self-star'] as const,
present(data, grant) {
if (data.user.starredRepositories?.totalCount >= 1000) {
grant('star-gazer', "I'm a star gazer!").evidence(
"I've starred over 1000 repositories!",
)
}
+
+ const selfStars: { nameWithOwner: string; url: string }[] = []
+ for (const repo of data.starredRepositories) {
+ if (repo.owner.login === data.user.login) {
+ selfStars.push({ nameWithOwner: repo.nameWithOwner, url: repo.url })
+ }
+ }
+
+ if (selfStars.length >= 1) {
+ grant('self-star', `I've starred ${selfStars.length} my own repositories.`)
+ .evidence(selfStars.map((x) => `- <a href="${x.url}">${x.nameWithOwner}</a>`).join('\n'))
+ }
},
})
src/task/stars/stars.graphql
@@ -1,5 +1,10 @@
fragment StarredRepo on Repository {
+ name
+ owner {
+ login
+ }
nameWithOwner
+ url
description
stargazers {
totalCount
src/task/stars/stars.graphql.ts
@@ -2,7 +2,12 @@
const StarredRepo = `#graphql
fragment StarredRepo on Repository {
+ name
+ owner {
+ login
+ }
nameWithOwner
+ url
description
stargazers {
totalCount
@@ -23,7 +28,12 @@ fragment StarredRepo on Repository {
}`
export type StarredRepo = {
+ name: string
+ owner: {
+ login: string
+ }
nameWithOwner: string
+ url: string
description: string | null
stargazers: {
totalCount: number