diff --git a/src/routes/[slug]/+page.js b/src/routes/[slug]/+page.js index f89b86b..28987ae 100644 --- a/src/routes/[slug]/+page.js +++ b/src/routes/[slug]/+page.js @@ -2,16 +2,14 @@ let user_details; export async function load({ params, fetch }) { let username = params.slug; - console.log(username); try { const response = await fetch( - `http://smaran.ddns.net:3000/records?user=${username}` + `https:/hacknight.navinshrinivas.com/records?user=${username}` ); if (!response.ok) { throw new Error(response.status, "Reddy Anna Is Not Talking"); } else { user_details = await response.json(); - console.log(user_details); return { user_details }; diff --git a/src/routes/[slug]/+page.svelte b/src/routes/[slug]/+page.svelte index c92a669..73e5f95 100644 --- a/src/routes/[slug]/+page.svelte +++ b/src/routes/[slug]/+page.svelte @@ -3,12 +3,31 @@ export let data; let user_details = data.user_details; + let user_details_grouped = user_details.reduce((accumulator, current) => { + const key = current.Pullreq_url; + if (!accumulator[key]) { + accumulator[key] = []; + } + accumulator[key].push(current); + return accumulator; + }, {}); + + user_details_grouped = Object.values(user_details_grouped); + + const latestPullRequests = Object.values( + user_details.reduce((accumulator, current) => { + const key = current.Pullreq_url; + if (!accumulator[key]) { + accumulator[key] = current; + } + return accumulator; + }, {}) + );
- - +
PULL REQUEST HISTORY
- {#each user_details as user} + {#each user_details_grouped as pr_arr}
-

{user.Points_allotted}

-
- Maintainer: {user.Maintainer_name} -

Timestamp: {user.CreatedAt}

-
- - - + {#each pr_arr as pr, i} + {#if i == 0} +

+ {pr.Points_allotted} +

+
+ Maintainer: {pr.Maintainer_name} +

+ {new Date(pr.CreatedAt).toLocaleDateString() + + " " + + new Date(pr.CreatedAt).toLocaleTimeString()} +

+
+ + + + {#if pr_arr.length !== 1} +
Previous Points:
+
+ {/if} + {:else} +
+ {pr.Points_allotted} +
+
+ {/if} + {/each}
{/each}