Skip to content

Commit

Permalink
fix: correct top repositories distribution and name concatenation
Browse files Browse the repository at this point in the history
  • Loading branch information
0-vortex committed Apr 4, 2023
1 parent 1d15cd3 commit 24bfb15
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 61 deletions.
2 changes: 2 additions & 0 deletions src/github/github.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export class GithubService {
}
}`);

this.logger.debug(`Rate limit: ${JSON.stringify(rateLimit)}`);

return rateLimit;
}
}
122 changes: 64 additions & 58 deletions src/github/gql/get-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,93 +17,99 @@ const getUser = (username: string, dateSince: string) => ({
query ($username: String!, $dateSince: DateTime) {
user(login: $username) {
id,
avatarUrl,
bio,
bioHTML,
company,
companyHTML,
createdAt,
email,
hasSponsorsListing,
isBountyHunter,
isCampusExpert,
isDeveloperProgramMember,
isEmployee,
isGitHubStar,
isHireable,
isSiteAdmin,
location,
login,
monthlyEstimatedSponsorsIncomeInCents,
name,
url,
pronouns,
resourcePath,
totalSponsorshipAmountAsSponsorInCents,
websiteUrl,
twitterUsername,
id
avatarUrl
bio
bioHTML
company
companyHTML
createdAt
email
hasSponsorsListing
isBountyHunter
isCampusExpert
isDeveloperProgramMember
isEmployee
isGitHubStar
isHireable
isSiteAdmin
location
login
monthlyEstimatedSponsorsIncomeInCents
name
url
pronouns
resourcePath
totalSponsorshipAmountAsSponsorInCents
websiteUrl
twitterUsername
organization(login: "open-sauced") {
id,
avatarUrl,
name,
url,
id
avatarUrl
name
url
updatedAt
},
organizations(first: 10, orderBy: {field: CREATED_AT, direction: ASC}) {
}
organizations(first: 10, orderBy: { field: CREATED_AT, direction: ASC }) {
nodes {
id,
avatarUrl,
name,
url,
id
avatarUrl
name
url
updatedAt
}
},
}
socialAccounts(first: 10) {
nodes {
displayName,
provider,
displayName
provider
url
}
},
}
status {
id,
emoji,
message,
id
emoji
message
organization {
id
}
},
repositories(first: 100, orderBy: {field: PUSHED_AT, direction: DESC}) {
}
repositories(first: 100, orderBy: { field: PUSHED_AT, direction: DESC }) {
nodes {
name
primaryLanguage {
name
},
languages(first: 10, orderBy: {field: SIZE, direction: DESC}) {
}
languages(first: 10, orderBy: { field: SIZE, direction: DESC }) {
edges {
node {
id,
name,
id
name
color
},
}
size
},
totalSize,
}
totalSize
totalCount
},
}
pushedAt
}
},
topRepositories(first: 10, orderBy: {field: PUSHED_AT, direction: DESC}, since: $dateSince) {
}
topRepositories(
first: 100
orderBy: { field: PUSHED_AT, direction: DESC }
since: $dateSince
) {
nodes {
name,
name
owner {
login
avatarUrl
},
}
isPrivate
primaryLanguage {
name
},
}
pushedAt
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/social-card/social-card.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class SocialCardService {

return {
langs: [],
repos: user.topRepositories.nodes as Repository[],
repos: user.topRepositories.nodes?.filter(repo => !repo?.isPrivate && repo?.owner.login !== username) as Repository[],
avatarUrl: `${String(user.avatarUrl)}&size=150`,
};
}
Expand Down
5 changes: 3 additions & 2 deletions src/social-card/templates/user-profile-repos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import repoIconWithName from "./repo-icon-with-name";
import { Repository } from "@octokit/graphql-schema";

const userProfileRepos = (repos: Repository[]): string => {
const repoList = repos.map(({ name, owner: { avatarUrl } }) => repoIconWithName(`${name.substring(0, 15)}${name.length > 15 ? "..." : ""}`, `${String(avatarUrl)}&size=40`));
const repoList = repos.map(({ name, owner: { avatarUrl } }) =>
repoIconWithName(`${name.substring(0, 15).replace(/\.+$/, "")}${name.length > 15 ? "..." : ""}`, `${String(avatarUrl)}&size=40`));

return `${repoList.slice(0, 3).join("")}${repoList.length > 3
return `${repoList.slice(0, 4).join("")}${repoList.length > 4
? `<h2 style="
width: 39px;
height: 37px;
Expand Down

0 comments on commit 24bfb15

Please sign in to comment.