Skip to content

Commit

Permalink
fix: correct languages displaying less than 0.5%
Browse files Browse the repository at this point in the history
  • Loading branch information
0-vortex committed Apr 9, 2023
1 parent 6efe0e6 commit bee0e6e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
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 @@ -114,7 +114,7 @@ export class SocialCardService {
const hash = `users/${String(id)}.png`;
const fileUrl = `${this.s3FileStorageService.getCdnEndpoint()}${hash}`;
const hasFile = await this.s3FileStorageService.fileExists(hash);
const today3daysAgo = new Date((new Date).setDate((new Date).getDate() - 0.001));
const today3daysAgo = new Date((new Date).setDate((new Date).getDate() - 3));

if (hasFile) {
// route to s3
Expand Down
10 changes: 7 additions & 3 deletions src/social-card/templates/user-langs.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { Language } from "@octokit/graphql-schema";

const userLangs = (langs: (Language & { size: number })[], totalCount = 0, joinLiteral = "") =>
langs
const userLangs = (langs: (Language & { size: number })[], totalCount = 0, joinLiteral = "") => {
const filteredLangs = langs
.filter(({ size }) => size > 0 && !((size / totalCount) * 100 < 0.5));

return filteredLangs
.map(({ color, size }) => {
const realPercent = size / totalCount * 100;
const realPercent = Math.round(size / totalCount * 100);

return `<div tw="h-12px ${color ? `bg-[${color}]` : "bg-black"}" style="width: ${totalCount > 0 ? realPercent : 100 / langs.length}%"/>`;
})
.join(joinLiteral);
};

export default userLangs;

0 comments on commit bee0e6e

Please sign in to comment.