Skip to content

Add Description along with user and org avatar#523

Open
DuttaNeel07 wants to merge 11 commits into
pointblank-club:stagingfrom
DuttaNeel07:desc
Open

Add Description along with user and org avatar#523
DuttaNeel07 wants to merge 11 commits into
pointblank-club:stagingfrom
DuttaNeel07:desc

Conversation

@DuttaNeel07

Copy link
Copy Markdown
Contributor

Summary: What does this PR do?

Changes Made

Describe the changes you've made in this PR:

  • Feature implementation
  • Bug fix
  • Documentation update
  • Code refactoring
  • Configuration changes
  • Other (please specify)

Type of Change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Documentation update
  • Performance improvement
  • Code cleanup or refactor

How Has This Been Tested?

Describe the tests you ran:

  • Unit tests
  • Integration tests
  • Manual tests
  • Other (please specify)

Please describe the test cases and expected behavior:

  1. Recreated the existing data in official db in local db and ran backfilling function, worked as expected i.e added desc, org avatar and user avatar to each contribution

Screenshots (if applicable)

Documentation

  • I have updated the documentation accordingly
  • Documentation update is not required

Comments:

Reviewer Notes

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the OSS contributions pipeline to carry contribution descriptions and avatar/profile metadata through scraping → persistence → API → dashboard UI, and introduces admin endpoints to backfill these fields for existing records.

Changes:

  • Added desc and avatar URL fields to contribution/org/user models and OSS data types.
  • Enhanced GitLab scraping to populate org + user avatar URLs; updated aggregations/API responses to include description/avatar fields and to exclude Point Blank orgs.
  • Added admin backfill routes/functions to populate missing descriptions and avatar fields for existing contributions; updated dashboard cards to render avatars.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
lib/server/scrapers/types.ts Extends RawContribution with optional desc and userAvatarUrl.
lib/server/scrapers/gitlab.ts Adds URL normalization + caching and populates org/user avatar + org URL for GitLab MRs.
lib/server/scrapers/github.ts Persists PR body into desc during GitHub scraping.
lib/server/contributionsV2.ts Stores new fields, filters Point Blank orgs, extends aggregates/queries, and adds backfill functions.
lib/oss.ts Threads description/avatar fields into normalized OSS org/contributor outputs.
lib/db/models/users.ts Adds avatarUrl to User schema.
lib/db/models/orgsV2.ts Makes org avatar/html URLs optional with defaults.
lib/db/models/contributionsV2.ts Adds desc, orgAvatarUrl, orgHtmlUrl, userAvatarUrl to schema/interface.
hooks/useOssDashboardData.ts Removes an unused type import.
components/oss/widgets/OssStatCard.tsx Simplifies stat card props (removes icon).
components/oss/widgets/OssOrganizationPreviewCard.tsx Renders org avatar (or initial) in preview card layout.
components/oss/widgets/OssOrganizationCard.tsx Renders org avatar (or initial) in full org card layout.
components/oss/widgets/OssContributorPreviewCard.tsx Renders contributor avatar in preview card layout.
components/oss/widgets/OssContributorCard.tsx Renders contributor avatar in full contributor card layout.
components/oss/types.ts Adds description/avatar fields to OSS dashboard TS types.
components/oss/OssDashboard.tsx Wires org/contributor avatar + descriptions into dashboard view-models; adds empty-array constants.
components/oss/modules/OssOverviewSection.tsx Removes icon usage for stat cards.
app/api/contributionsV2/route.ts Excludes Point Blank orgs in view=user and returns desc/avatar fields per PR entry.
app/api/contributionsV2/backfillAvatar/route.ts Adds admin endpoint to start avatar backfill job.
app/api/contributionsV2/backfill/route.ts Adds admin endpoint to start description backfill job.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

};
}

export async function getGlobalStats() {
Comment thread lib/server/contributionsV2.ts Outdated
Comment on lines +123 to +129
if (c.desc != null && c.desc !== "") {
setFields.desc = c.desc;
}

for (const c of contributions) {
if (c.userAvatarUrl) {
setFields.userAvatarUrl = normalizeExternalUrl(c.userAvatarUrl);
}
Comment on lines 262 to +270
$group: {
_id: "$orgLogin",
totalMergedPRs: { $sum: 1 },
contributors: { $addToSet: "$username" },
memberNames: { $addToSet: "$memberName" },
platforms: { $addToSet: "$platform" },
descriptions: { $addToSet: "$desc" },
contributionOrgAvatars: { $addToSet: "$orgAvatarUrl" },
contributionOrgUrls: { $addToSet: "$orgHtmlUrl" },
Comment on lines +342 to 357
$group: {
_id: "$memberName",
usernames: { $addToSet: "$username" },
memberName: { $first: "$memberName" },
totalMergedPRs: { $sum: 1 },
githubPRs: {
$sum: { $cond: [{ $eq: ["$platform", "github"] }, 1, 0] },
},
},
{
$project: {
_id: 0,
username: { $arrayElemAt: ["$usernames", 0] }, // pick one
memberName: 1,
totalMergedPRs: 1,
githubPRs: 1,
gitlabPRs: 1,
orgs: 1,
platforms: 1,
totalOrgs: { $size: "$orgs" },
gitlabPRs: {
$sum: { $cond: [{ $eq: ["$platform", "gitlab"] }, 1, 0] },
},
orgs: { $addToSet: "$orgLogin" },
platforms: { $addToSet: "$platform" },
userAvatarUrl: { $max: "$userAvatarUrl" },
descriptions: { $addToSet: "$desc" },
},
Comment on lines 296 to 302
orgAvatarUrl,
orgHtmlUrl,
title: pr.title,
desc: pr.body as string,
url: pr.html_url,
mergedAt: new Date(mergedAt),
});
Comment on lines 403 to 412
memberName, username, platform: "github",
repoFullName,
orgLogin: eff.owner.login,
orgAvatarUrl: eff.owner.avatar_url,
orgHtmlUrl: `https://github.com/${eff.owner.login}`,
title: pr.title,
desc: pr.body as string,
url: pr.html_url,
mergedAt: new Date(mergedAt),
});
Comment on lines 87 to 94
contributors: org.contributors.map((login) => ({
id: login,
name: loginToName.get(login) ?? login,
login,
platform: getPreferredPlatform(org.platforms),
avatarUrl: contributorsJson.data.find((c) => c.username === login)
?.userAvatarUrl,
})),
Comment thread lib/server/scrapers/gitlab.ts Outdated
Comment on lines +133 to +145
const fullPath = group?.full_path ?? namespace.full_path;
if (!fullPath?.includes("/")) return "";

const pathParts = fullPath.split("/").filter(Boolean);
while (pathParts.length > 1) {
pathParts.pop();
const parentPath = pathParts.join("/");
const parentGroup = await fetchGitLabJson<GitLabGroup>(
`/groups/${encodeURIComponent(parentPath)}`,
);
const parentAvatar = normalizeGitLabUrl(parentGroup?.avatar_url);
if (parentAvatar) return parentAvatar;
}
import { NextRequest, NextResponse } from "next/server";
import { backfillOrgAndUserAvatars } from "@/lib/server/contributionsV2";

// POST /api/admin/backfill-avatars?key=<SCRAPE_SECRET>
Comment thread app/api/contributionsV2/route.ts Outdated
Comment on lines +74 to +88
const GITLAB_ORIGIN = "https://gitlab.com";
const POINT_BLANK_ORG_PATTERNS = [
/^point[-_\s]?blank$/i,
/^point[-_\s]?blank[-_\s]?club$/i,
];
const POINT_BLANK_ORG_EXCLUSION = {
$nor: POINT_BLANK_ORG_PATTERNS.map((pattern) => ({ orgLogin: pattern })),
};

function normalizeExternalUrl(url?: string | null) {
if (!url) return "";
if (url.startsWith("http://") || url.startsWith("https://")) return url;
if (url.startsWith("/")) return `${GITLAB_ORIGIN}${url}`;
return url;
}
yugeshweb and others added 2 commits May 22, 2026 19:29
* Activites card mobile responsive update

* Domain Addition
* feat: add Dockerfile and .dockerignore for containerization

* feat: refactor API calls to use server functions and some changes in dockerfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants