diff --git a/app/api/optimism-retropgf-3/crons/route.ts b/app/api/optimism-retropgf-3/crons/route.ts index 6fa77ab1..07ebcd01 100644 --- a/app/api/optimism-retropgf-3/crons/route.ts +++ b/app/api/optimism-retropgf-3/crons/route.ts @@ -309,9 +309,9 @@ const processAllProjects = async () => { const processCron = async () => { console.log("processCron started"); - createTableIfNotExists().then(() => { + await createTableIfNotExists().then(async () => { console.log("processCron::createTableIfNotExists done"); - processAllProjects().then(() => { + await processAllProjects().then(() => { console.log("processCron::processAllProjects done"); }); }); diff --git a/app/optimism-retropgf-3/page.tsx b/app/optimism-retropgf-3/page.tsx index 6126e00a..2babccbe 100644 --- a/app/optimism-retropgf-3/page.tsx +++ b/app/optimism-retropgf-3/page.tsx @@ -19,7 +19,7 @@ import Icon from "@/components/layout/Icon"; import { useTheme } from "next-themes"; import ShowLoading from "@/components/layout/ShowLoading"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; -import { uniq } from "lodash"; +import { last, uniq } from "lodash"; import moment from "moment"; import Image from "next/image"; import Link from "next/link"; @@ -115,6 +115,19 @@ export default function Page() { const { theme } = useTheme(); + const lastUpdatedString = useMemo(() => { + if (!projectsResponse) return null; + + const oldest = projectsResponse.projects.reduce((prev, curr) => { + return prev.last_updated < curr.last_updated ? prev : curr; + }); + + const lastUpdated = oldest.last_updated; + + return moment(lastUpdated).fromNow(); + }, [projectsResponse]); + + const getProjectsCombinedFundingSourcesByCurrency = useCallback( (fundingSources: ProjectFundingSource[]) => { const combinedFundingSources: { @@ -323,11 +336,10 @@ export default function Page() { rel="noopener noreferrer" target="_blank" href={`https://etherscan.io/address/${info.row.original.applicant.address.address}`} - className={`rounded-full px-1 py-0 border border-forest-900/20 dark:border-forest-500/20 font-mono text-[10px] ${ - info.row.original.applicant.address.resolvedName.name - ? "text-forest-900 dark:text-forest-500" - : "text-forest-900/50 dark:text-forest-500/50" - } hover:bg-forest-900/10 dark:hover:bg-forest-500/10`} + className={`rounded-full px-1 py-0 border border-forest-900/20 dark:border-forest-500/20 font-mono text-[10px] ${info.row.original.applicant.address.resolvedName.name + ? "text-forest-900 dark:text-forest-500" + : "text-forest-900/50 dark:text-forest-500/50" + } hover:bg-forest-900/10 dark:hover:bg-forest-500/10`} > {info.row.original.applicant.address.resolvedName.name ? ( <>{info.row.original.applicant.address.resolvedName.name} @@ -465,15 +477,14 @@ export default function Page() { className="relative" style={{ height: "2px", - width: `${ - (getProjectsCombinedFundingSourcesByCurrency( + width: `${(getProjectsCombinedFundingSourcesByCurrency( + info.row.original.funding_sources, + )["TOTAL"] / + getProjectsCombinedFundingSourcesByCurrency( info.row.original.funding_sources, - )["TOTAL"] / - getProjectsCombinedFundingSourcesByCurrency( - info.row.original.funding_sources, - )["TOTAL"]) * + )["TOTAL"]) * 100.0 - }%`, + }%`, }} >
@@ -628,13 +636,12 @@ export default function Page() { style={{ height: "2px", - width: `${ - (getProjectsCombinedFundingSourcesByCurrency( - info.row.original.funding_sources, - )["TOTAL"] / - totalFundingAmounts["TOTAL"]) * + width: `${(getProjectsCombinedFundingSourcesByCurrency( + info.row.original.funding_sources, + )["TOTAL"] / + totalFundingAmounts["TOTAL"]) * 100.0 - }%`, + }%`, // right with bases on bottom and right }} > @@ -779,32 +786,32 @@ export default function Page() { // }, }, }, - { - header: "Last Updated", - accessorKey: "last_updated", - // size: 15, - cell: (info) => ( -
- {moment(info.row.original.last_updated).fromNow(true)} -
- ), - meta: { - headerAlign: { - marginLeft: "auto", - flexDirection: "row-reverse", - }, - }, - sortingFn: (rowA, rowB) => { - const a = moment(rowA.original.last_updated).unix(); - const b = moment(rowB.original.last_updated).unix(); - - // If both are equal, return 0. - if (a === b) return 0; - - // Otherwise, sort by whether a is greater than or less than b. - return a > b ? 1 : -1; - }, - }, + // { + // header: "Last Updated", + // accessorKey: "last_updated", + // // size: 15, + // cell: (info) => ( + //
+ // {moment(info.row.original.last_updated).fromNow(true)} + //
+ // ), + // meta: { + // headerAlign: { + // marginLeft: "auto", + // flexDirection: "row-reverse", + // }, + // }, + // sortingFn: (rowA, rowB) => { + // const a = moment(rowA.original.last_updated).unix(); + // const b = moment(rowB.original.last_updated).unix(); + + // // If both are equal, return 0. + // if (a === b) return 0; + + // // Otherwise, sort by whether a is greater than or less than b. + // return a > b ? 1 : -1; + // }, + // }, ], [ @@ -826,7 +833,7 @@ export default function Page() { projects.map( (d) => getProjectsCombinedFundingSourcesByCurrency(d.funding_sources)[ - "USD" + "USD" ], ), ).length, @@ -834,7 +841,7 @@ export default function Page() { projects.map( (d) => getProjectsCombinedFundingSourcesByCurrency(d.funding_sources)[ - "OP" + "OP" ], ), ).length, @@ -854,7 +861,7 @@ export default function Page() { data.map( (d) => getProjectsCombinedFundingSourcesByCurrency(d.funding_sources)[ - "USD" + "USD" ], ), ).length, @@ -862,7 +869,7 @@ export default function Page() { data.map( (d) => getProjectsCombinedFundingSourcesByCurrency(d.funding_sources)[ - "OP" + "OP" ], ), ).length, @@ -905,9 +912,8 @@ export default function Page() { } td { - border-color: ${ - theme === "light" ? "rgba(0,0,0,0.16)" : "rgba(255,255,255,0.16)" - }; + border-color: ${theme === "light" ? "rgba(0,0,0,0.16)" : "rgba(255,255,255,0.16)" + }; border-width:1px; border-style:solid none; padding:5px 10px; @@ -937,6 +943,15 @@ export default function Page() { dataValidating={[projectsValidating]} fullScreen /> +
+
+ {lastUpdatedString && ( +
+ Last Updated: {lastUpdatedString} +
+ )} +
+
{Style}
@@ -962,9 +977,8 @@ export default function Page() {
{dataUniqueValues[header.id] === - projectsUniqueValues[header.id] ? ( + projectsUniqueValues[header.id] ? ( projectsUniqueValues[ header.id ].toLocaleString() @@ -1022,21 +1036,19 @@ export default function Page() { {projectsUniqueValues?.hasOwnProperty(header.id) && dataUniqueValues?.hasOwnProperty(header.id) && (
- parentRef.current.scrollHeight - - parentRef.current.clientHeight - - 30) - ? "fade-edge-div-vertical-hidden" - : "fade-edge-div-vertical" + parentRef.current.scrollHeight - + parentRef.current.clientHeight - + 30) + ? "fade-edge-div-vertical-hidden" + : "fade-edge-div-vertical" } }`} > @@ -1110,15 +1122,14 @@ export default function Page() { // ? "sticky top-0 z-20" // : "sticky top-0 left-0 z-30" "" - } bg-white dark:bg-forest-1000 whitespace-nowrap`} + } bg-white dark:bg-forest-1000 whitespace-nowrap`} > {header.isPlaceholder ? null : (
{row.getVisibleCells().map((cell, i) => {