Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSoC 2024: GitHub Discussion UI at Home, Discussion and Contributor's route #463

Merged
merged 82 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
b04efab
GSoC_Week_1:Refactor present scrapper into typescript and addition in…
dgparmar14 Jun 6, 2024
6669679
GSoC_Week_1:Refactor present scrapper into typescript and addition in…
dgparmar14 Jun 6, 2024
37965a3
Delete newGt.ts
dgparmar14 Jun 6, 2024
95804ed
remove unwated changes
dgparmar14 Jun 6, 2024
57e9445
Merge branch 'refactor-scrapper-gsoc' of https://github.com/dgparmar1…
dgparmar14 Jun 6, 2024
0bb6d00
Scraper githu.ts divided into different files for better understanding
dgparmar14 Jun 8, 2024
6cc5dac
fix scraper setup
rithviknishad Jun 14, 2024
a1491b9
Integrate Github Discussion in scraper and update scraper-dry-run wor…
dgparmar14 Jun 18, 2024
7583a62
Removing dry-run work flow error (date-fns)
dgparmar14 Jun 18, 2024
1d51cd1
Fixing scraper-dry-run date error by puting null as a default value f…
dgparmar14 Jun 24, 2024
0e5fde7
Fixing scraper-dry-run failing
dgparmar14 Jun 24, 2024
8596095
Fixing scraper-dry-run failing
dgparmar14 Jun 24, 2024
30b092a
Fixing scraper-dry-run failing
dgparmar14 Jun 24, 2024
8a3de03
Fixing scraper-dry-run failing (Genrate markdown files)
dgparmar14 Jun 24, 2024
6e31084
Fixing scraper-dry-run failing (Genrate markdown files)
dgparmar14 Jun 24, 2024
8c62674
Fixing scraper-dry-run failing (Genrate markdown files)
dgparmar14 Jun 24, 2024
0e807d8
Fixing scraper-dry-run failing (Genrate markdown files)
dgparmar14 Jun 24, 2024
a62a9d9
Merge branch 'main' into refactor-scrapper-gsoc
rithviknishad Jun 26, 2024
6c14a72
Suggested cahnges done
dgparmar14 Jun 27, 2024
60bf70e
Merge branch 'refactor-scrapper-gsoc' of https://github.com/dgparmar1…
dgparmar14 Jun 27, 2024
4fd59d4
Update test schema for discussion
dgparmar14 Jun 27, 2024
8980042
resolve-dry-run error with pnpm
dgparmar14 Jun 27, 2024
68f8fd4
Revert accidental cahnges in scraper0dry-run.yaml
dgparmar14 Jun 27, 2024
8675c01
Revert accidental cahnges in scraperdry-run.yaml
dgparmar14 Jun 27, 2024
638f272
dotenv used in generateNewContrbutors.js
dgparmar14 Jun 27, 2024
386448d
remove: dotenv used in generateNewContrbutors.js
dgparmar14 Jun 27, 2024
eaadb2a
Fix path for data repository to solve dry-run error
dgparmar14 Jun 27, 2024
a5f2371
update pnpm-lock.yaml
dgparmar14 Jun 27, 2024
d66fae9
Store seprately all discussion in discussion folder
dgparmar14 Jun 27, 2024
cac83cf
Update discussion schema
dgparmar14 Jun 28, 2024
af061d5
Update discussion schema
dgparmar14 Jun 28, 2024
83df93d
Merge branch 'coronasafe:main' into refactor-scrapper-gsoc
dgparmar14 Jun 28, 2024
122d662
Update scraper-dry-run.yaml
dgparmar14 Jun 28, 2024
3ca99f2
Merge branch 'refactor-scrapper-gsoc' of https://github.com/dgparmar1…
dgparmar14 Jun 28, 2024
1c57cc7
Update scraper-dry-run.yaml and fix some typos
dgparmar14 Jun 28, 2024
05a8b40
Update scraper-dry-run.yaml
dgparmar14 Jun 28, 2024
e678e68
Remove casting in fetchEvents.ts
dgparmar14 Jun 28, 2024
2dc5b94
fix type error
rithviknishad Jun 28, 2024
7ea2a3f
Fix type errors
dgparmar14 Jul 1, 2024
cdda148
Modify types and remove all types error from scraper
dgparmar14 Jul 2, 2024
4a5dd7e
Modify types and remove all types error from scraper
dgparmar14 Jul 2, 2024
6609994
Description added to discussion scraper
dgparmar14 Jul 5, 2024
e3bb35d
Description added to discussion scraper
dgparmar14 Jul 5, 2024
9337484
Discussion UI created at home, disucssions and cotrnbutors profile route
dgparmar14 Jul 12, 2024
464efd6
uncomment in scraper
dgparmar14 Jul 12, 2024
0141997
Merge pull request #458 from dgparmar14/refactor-scrapper-gsoc
rithviknishad Jul 12, 2024
68f9b5e
Update Github Dicussions to Discussion
dgparmar14 Jul 13, 2024
9d1c102
Point mechanism for discussions and responsiveness added
dgparmar14 Jul 16, 2024
5c90cd4
Merge branch 'coronasafe:main' into gsoc-discussion-ui
dgparmar14 Jul 16, 2024
59cddcf
Site map updated for gh-discussion
dgparmar14 Jul 16, 2024
a34f030
Merge branch 'gsoc/gh-discussions' into gsoc-discussion-ui
dgparmar14 Jul 16, 2024
a52d61e
type error fix in api.ts and modify logic of leaderboard for discussions
dgparmar14 Jul 16, 2024
92999ce
Merge branch 'gsoc-discussion-ui' of https://github.com/dgparmar14/le…
dgparmar14 Jul 16, 2024
9a9f63b
prose-h2 added to fix markdown bug
dgparmar14 Jul 16, 2024
83e062d
Modified suggested changes still one type error remaining
dgparmar14 Jul 18, 2024
a032253
Modified suggested changes still one type error remaining
dgparmar14 Jul 18, 2024
1ac9b0a
Chages done as per review
dgparmar14 Jul 19, 2024
02508f8
fix type error in api.ts mismatch in return type of discussion
dgparmar14 Jul 19, 2024
5cfe6c6
Add suspense boundary for discussions filter
rithviknishad Jul 19, 2024
d48fe37
fix open in github button responsiveness issue
rithviknishad Jul 19, 2024
f1bab51
fix incorrect roots and remove unused imports
rithviknishad Jul 19, 2024
b89aaeb
Enable empathy badge and merge discussions with old data
dgparmar14 Jul 19, 2024
b67e6ee
requested changes are done participants logic in progress
dgparmar14 Jul 22, 2024
cc6993c
remove unnecessary `useMemo`
rithviknishad Jul 22, 2024
355b5ad
Implement logic to fetch discussion within daterange (updated or crea…
dgparmar14 Jul 22, 2024
66a86ab
Removing previous logic of fetch participants
dgparmar14 Jul 22, 2024
61c0521
Remove unwanted changes
dgparmar14 Jul 22, 2024
1a16748
Handle nullable values while scraping discussion
dgparmar14 Jul 22, 2024
1f7f36a
Modify testing if the discussion.json is empty or notpresent
dgparmar14 Jul 22, 2024
aa64d41
Fixing testing logic
dgparmar14 Jul 22, 2024
951dd45
Change in discussion scraper logic and modify reposName to repository…
dgparmar14 Jul 23, 2024
c0027fe
fix naming convetntions and discussion-schema-testing when there is n…
dgparmar14 Jul 23, 2024
1f210f5
Update tests/github-discussion-schema.test.mjs
rithviknishad Jul 23, 2024
dfd6af1
remove unused packages, scripts and upgraded package versions
rithviknishad Jul 25, 2024
0f6c0e8
remove unused methods
rithviknishad Jul 25, 2024
dbc4827
move markdown render to server side
rithviknishad Jul 25, 2024
5b471b0
check if discussions dir. exists before reading
rithviknishad Jul 25, 2024
c0deaa1
Merge pull request #466 from dgparmar14/gsoc-discussion-ui
rithviknishad Jul 25, 2024
b3a222f
support for scraper workflow to run on non-main branches
rithviknishad Jul 25, 2024
322fdde
update scraper action workflow
rithviknishad Jul 25, 2024
9d773d5
update data repo dir. in scraper workflow
rithviknishad Jul 25, 2024
cd52504
update data dir. in scraper workflow
rithviknishad Jul 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ DATA_SOURCE="https://github.com/coronasafe/leaderboard-data.git"
# SLACK_EOD_BOT_SIGNING_SECRET=<Slack EOD Bot App's Signing Secret>

## -- Features -- ##
NEXT_PUBLIC_FEATURES=Leaderboard,Contributors,Feed,Releases,Projects
NEXT_PUBLIC_FEATURES=Leaderboard,Contributors,Feed,Releases,Projects,Discussions
37 changes: 16 additions & 21 deletions .github/workflows/scraper-dry-run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,25 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: setup python
uses: actions/setup-python@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
python-version: "3.10"
node-version: "20.14.0"

- name: Install pnpm
run: npm install -g pnpm

- name: Install dependencies
run: pip install -r scraper/requirements.txt
run: pnpm install --frozen-lockfile
working-directory: scraper

- name: Build the project
run: pnpm build
working-directory: scraper

- name: Scrape data from GitHub
run: python scraper/src/github.py ${{ github.repository_owner }} data/github -l DEBUG
run: pnpm start ${{ github.repository_owner }} ../data/github
working-directory: scraper
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -39,40 +48,26 @@ jobs:
run: node scripts/generateNewContributors.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/upload-artifact@v4
with:
name: output
retention-days: 5
path: |
data
contributors

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"


- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install --frozen-lockfile

Expand Down
38 changes: 26 additions & 12 deletions .github/workflows/scraper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ on:
slack-eod-channel:
required: false
type: string
leaderboard_ref:
required: false
type: string
default: main
description: A specific branch of scraper that is to be used.
secrets:
GIT_ACCESS_TOKEN:
required: true
Expand All @@ -22,35 +27,44 @@ jobs:
with:
repository: coronasafe/leaderboard
path: ./leaderboard
ref: ${{ inputs.leaderboard_ref }}
sparse-checkout: |
scraper
scripts

- name: setup python
uses: actions/setup-python@v3
- uses: actions/setup-node@v3
with:
python-version: "3.10"
node-version: "20.14.0"
- run: npm install -g pnpm

- name: Install dependencies
run: pip install -r scraper/requirements.txt
- run: pnpm install --frozen-lockfile
working-directory: scraper

- name: Scrape GitHub data
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
command: python scraper/src/github.py ${{ github.repository_owner }} data/github -l DEBUG
on_retry_command: git checkout .
- run: pnpm build
working-directory: scraper

- name: Scrape data from GitHub
run: pnpm start ${{ github.repository_owner }} ../../data/github
working-directory: scraper
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/setup-python@v3
with:
python-version: "3.10"

- name: Install dependencies
run: pip install -r scraper/requirements.txt

- name: Scrape EOD updates from Slack Channel
if: ${{ env.SLACK_API_TOKEN && env.SLACK_CHANNEL }}
run: python scraper/src/slack.py --lookback_days=2
env:
SLACK_API_TOKEN: ${{ secrets.SLACK_API_TOKEN }}
SLACK_CHANNEL: ${{ inputs.slack-eod-channel }}

- run: mkdir -p contributors

- name: Generate markdown files for new contributors
run: node scripts/generateNewContributors.js
env:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
.pnp.js
bun.lockb
package-lock.json
pnpm-lock.yaml

# testing
/coverage
Expand Down
7 changes: 6 additions & 1 deletion app/api/leaderboard/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export const getLeaderboardData = async (
.filter(
(contributor) => roles.length == 0 || roles.includes(contributor.role),
)
.filter((contributor) => {
if (sortBy) {
return contributor.summary[sortBy] ?? 0 > 0;
}
})
.sort((a, b) => {
if (sortBy === "pr_stale") {
return b.activityData.pr_stale - a.activityData.pr_stale;
Expand Down Expand Up @@ -55,7 +60,7 @@ export const getLeaderboardData = async (
},
highlights: {
...contributor.summary,
pr_stale: contributor.activityData.pr_stale,
pr_stale: contributor.activityData.pr_stale ?? 0,
},
};
});
Expand Down
2 changes: 1 addition & 1 deletion app/contributors/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import BadgeIcons from "../../../components/contributors/BadgeIcons";
import GithubActivity from "../../../components/contributors/GithubActivity";
import GraduateAttributeBadge from "../../../components/contributors/GraduateAttributeBadge";
import InfoCard from "../../../components/contributors/InfoCard";
import React, { Suspense } from "react";
import React from "react";
import clsx from "clsx";
import { formatDuration, parseDateRangeSearchParam } from "@/lib/utils";
import Markdown from "@/components/Markdown";
Expand Down
2 changes: 1 addition & 1 deletion app/contributors/sitemap.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { sitemapEntry } from "@/app/sitemap";
import { getContributors, getContributorsSlugs } from "@/lib/api";
import { getContributors } from "@/lib/api";
import { MetadataRoute } from "next";

export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
Expand Down
35 changes: 35 additions & 0 deletions app/discussions/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Metadata } from "next";
import { env } from "@/env.mjs";
import { notFound } from "next/navigation";
import { featureIsEnabled } from "@/lib/utils";
import FilterDiscussions from "../../components/discussions/FilterDiscussions";
import { categories } from "../../lib/discussion";
import DiscussionLeaderboard from "../../components/discussions/DiscussionLeaderboard";
import { Suspense } from "react";

export const metadata: Metadata = {
title: `Disucssions | ${env.NEXT_PUBLIC_PAGE_TITLE}`,
};

export default function DiscussionsLayout({
children,
}: {
children: React.ReactNode;
}) {
if (!featureIsEnabled("Discussions")) return notFound();

return (
<div className="mx-auto max-w-6xl p-5">
<div className="items-center gap-5 pb-8 lg:mt-10 lg:flex">
<h1 className="text-3xl sm:text-4xl">Disucssions</h1>
<Suspense fallback={<></>}>
<FilterDiscussions categories={categories} />
</Suspense>
</div>
<div className="flex w-full flex-col-reverse gap-3 lg:flex lg:flex-row">
{children}
<DiscussionLeaderboard />
</div>
</div>
);
}
19 changes: 19 additions & 0 deletions app/discussions/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { fetchGithubDiscussion } from "../../lib/discussion";
import GithubDiscussions from "../../components/discussions/GithubDiscussions";

interface Params {
searchParams: { [key: string]: string };
}

export default async function Page({ searchParams }: Params) {
const discussions = await fetchGithubDiscussion();

return (
discussions && (
<GithubDiscussions
discussions={discussions}
searchParams={searchParams}
/>
)
);
}
6 changes: 0 additions & 6 deletions app/issues/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import { env } from "@/env.mjs";
import octokit from "@/lib/octokit";
import Image from "next/image";
import Link from "next/link";
import { GoIssueOpened } from "react-icons/go";
import Markdown from "@/components/Markdown";
import ActiveProjects from "../projects/ActiveProjects";

const page = async () => {
Expand Down
2 changes: 1 addition & 1 deletion app/leaderboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default async function LeaderboardPage({ searchParams }: PageProps) {
const keyString = `search=${searchParams?.search}`;
return (
<section className="border-t border-secondary-300 bg-background text-foreground dark:border-secondary-700">
<div className="mx-auto max-w-6xl">
<div className="mx-auto max-w-7xl">
<Searchbar searchParams={searchParams} />
<div className="mx-4 border-secondary-600 xl:mx-0">
<Suspense
Expand Down
32 changes: 30 additions & 2 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { env } from "@/env.mjs";
import CommunityEngagemet from "@/app/CommunityEngagementSummary";
import { differenceInWeeks, parseISO } from "date-fns";
import { featureIsEnabled, formatDate } from "@/lib/utils";
import { fetchGithubDiscussion } from "../lib/discussion";
import GithubDiscussion from "@/components/discussions/GithubDiscussion";

export default async function Home() {
const contributors = (await getContributors())
Expand All @@ -21,7 +23,7 @@ export default async function Home() {
.includes(contributor.role) ?? true,
)
.sort((a, b) => b.weekSummary.points - a.weekSummary.points);

const discussions = await fetchGithubDiscussion(5);
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved
const startDate = parseISO(env.NEXT_PUBLIC_ORG_START_DATE);

return (
Expand Down Expand Up @@ -95,7 +97,33 @@ export default async function Home() {
</div>
</div>
)}

{discussions && (
<div className="mx-auto">
<div className="space-y-12">
<div className="flex items-center justify-between pr-2">
<h2 className="text-3xl font-bold tracking-tight sm:text-4xl">
Discussions
</h2>
<Link
href="/discussions"
className="flex items-center gap-1 rounded p-2 text-secondary-400 underline underline-offset-2 transition-all duration-200 ease-in-out hover:gap-2 hover:text-primary-200"
>
More
<MdOutlineArrowForwardIos />
</Link>
</div>
{discussions.map((discussion, index) => {
return (
<GithubDiscussion
key={index}
discussion={discussion}
minimal
/>
);
})}
</div>
</div>
)}
{featureIsEnabled("Projects") && (
<div className="mx-auto">
<div className="space-y-12">
Expand Down
1 change: 1 addition & 0 deletions app/sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default function sitemap(): MetadataRoute.Sitemap {
entry("/releases"),
entry("/leaderboard"),
entry("/issues"),
entry("/discussions"),
entry("/feed", { changeFrequency: "always", priority: 0.7 }),
];
}
9 changes: 5 additions & 4 deletions components/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@ import remarkGfm from "remark-gfm";
import remarkRehype from "remark-rehype";
import rehypeStringify from "rehype-stringify";
import clsx from "clsx";

export default async function Markdown(props: {
children: string;
className?: string;
}) {
const result = await unified()
const processedMarkdown = unified()
.use(remarkParse)
.use(remarkGfm)
.use(remarkRehype)
.use(rehypeStringify)
.process(props.children || "");
.processSync(props.children || "");

return (
<div className="prose font-inter text-sm leading-relaxed dark:prose-invert sm:text-base xl:text-left">
<div className="prose font-inter text-sm leading-relaxed dark:prose-invert prose-h2:mt-3 sm:text-base xl:text-left">
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved
<div
className={clsx(props.className ?? "")}
dangerouslySetInnerHTML={{ __html: result.toString() }}
dangerouslySetInnerHTML={{ __html: processedMarkdown.toString() }}
/>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions components/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export function Select({
<>
{showSelectionsAs ? (
showSelectionsAs == "tags" ? (
<div className="left-[-2.5rem] top-9 flex w-full flex-wrap gap-0.5">
<div className="-left-10 top-9 flex w-full flex-wrap gap-0.5">
{Array.isArray(value) &&
value?.length > 0 &&
value.length !== options.length ? (
Expand All @@ -129,7 +129,7 @@ export function Select({
)}
</div>
) : (
<div className="left-[-2.5rem] top-9 flex gap-0.5">
<div className="-left-10 top-9 flex gap-0.5">
{Array.isArray(value) &&
value.length > 0 &&
value.length !== options.length ? (
Expand Down
Loading
Loading