Skip to content

feat(insights): add permissioned feeds column to the publisher list #2541

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

Merged
merged 1 commit into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions apps/insights/src/components/Explanations/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ import { useMemo } from "react";
import { Explain } from "../Explain";
import { FormattedDate } from "../FormattedDate";

export const ExplainPermissioned = ({
scoreTime,
}: {
scoreTime?: Date | undefined;
}) => {
return (
<Explain size="xs" title="Permissioned Feeds">
<p>
This is the number of <b>Price Feeds</b> that a <b>Publisher</b> has
permissions to publish to. The publisher is not necessarily push data
for all the feeds they have access to, and some feeds may not be live
yet.
</p>
{scoreTime && <EvaluationTime scoreTime={scoreTime} />}
</Explain>
);
};

export const ExplainAverage = ({
scoreTime,
}: {
Expand Down
6 changes: 4 additions & 2 deletions apps/insights/src/components/Publishers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export const Publishers = async () => {
const toTableRow = ({
key,
rank,
permissionedFeeds,
inactiveFeeds,
activeFeeds,
averageScore,
Expand All @@ -155,8 +156,9 @@ const toTableRow = ({
return {
id: key,
ranking: rank,
activeFeeds: activeFeeds,
inactiveFeeds: inactiveFeeds,
permissionedFeeds,
activeFeeds,
inactiveFeeds,
averageScore,
...(knownPublisher && {
name: knownPublisher.name,
Expand Down
34 changes: 30 additions & 4 deletions apps/insights/src/components/Publishers/publishers-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ import styles from "./publishers-card.module.scss";
import { useQueryParamFilterPagination } from "../../hooks/use-query-param-filter-pagination";
import { CLUSTER_NAMES } from "../../services/pyth";
import { EntityList } from "../EntityList";
import { ExplainActive, ExplainInactive } from "../Explanations";
import {
ExplainPermissioned,
ExplainActive,
ExplainInactive,
} from "../Explanations";
import { NoResults } from "../NoResults";
import { PublisherTag } from "../PublisherTag";
import { Ranking } from "../Ranking";
Expand All @@ -43,6 +47,7 @@ type Props = {
type Publisher = {
id: string;
ranking: number;
permissionedFeeds: number;
activeFeeds: number;
inactiveFeeds: number;
averageScore: number;
Expand Down Expand Up @@ -99,6 +104,7 @@ const ResolvedPublishersCard = ({
(a, b, { column, direction }) => {
switch (column) {
case "ranking":
case "permissionedFeeds":
case "activeFeeds":
case "inactiveFeeds":
case "averageScore": {
Expand Down Expand Up @@ -131,6 +137,7 @@ const ResolvedPublishersCard = ({
id,
ranking,
averageScore,
permissionedFeeds,
activeFeeds,
inactiveFeeds,
...publisher
Expand All @@ -149,6 +156,7 @@ const ResolvedPublishersCard = ({
})}
/>
),
permissionedFeeds,
activeFeeds: (
<Link
href={`/publishers/${cluster}/${id}/price-feeds?status=Active`}
Expand Down Expand Up @@ -224,7 +232,12 @@ type PublishersCardContentsProps = Pick<Props, "className" | "explainAverage"> &
cluster: (typeof CLUSTER_NAMES)[number];
onChangeCluster: (value: (typeof CLUSTER_NAMES)[number]) => void;
rows: (RowConfig<
"ranking" | "name" | "activeFeeds" | "inactiveFeeds" | "averageScore"
| "ranking"
| "name"
| "permissionedFeeds"
| "activeFeeds"
| "inactiveFeeds"
| "averageScore"
> & { textValue: string })[];
}
);
Expand Down Expand Up @@ -299,6 +312,7 @@ const PublishersCardContents = ({
headerLoadingSkeleton={<PublisherTag isLoading />}
fields={[
{ id: "averageScore", name: "Average Score" },
{ id: "permissionedFeeds", name: "Permissioned Feeds" },
{ id: "activeFeeds", name: "Active Feeds" },
{ id: "inactiveFeeds", name: "Inactive Feeds" },
]}
Expand Down Expand Up @@ -339,11 +353,23 @@ const PublishersCardContents = ({
loadingSkeleton: <PublisherTag isLoading />,
allowsSorting: true,
},
{
id: "permissionedFeeds",
name: (
<>
FEEDS
<ExplainPermissioned />
</>
),
alignment: "center",
width: 30,
allowsSorting: true,
},
{
id: "activeFeeds",
name: (
<>
ACTIVE FEEDS
ACTIVE
<ExplainActive />
</>
),
Expand All @@ -355,7 +381,7 @@ const PublishersCardContents = ({
id: "inactiveFeeds",
name: (
<>
INACTIVE FEEDS
INACTIVE
<ExplainInactive />
</>
),
Expand Down
4 changes: 4 additions & 0 deletions apps/insights/src/services/clickhouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export const getPublishers = async (cluster: Cluster) =>
z.strictObject({
key: z.string(),
rank: z.number(),
permissionedFeeds: z
.string()
.transform((value) => Number.parseInt(value, 10)),
activeFeeds: z
.string()
.transform((value) => Number.parseInt(value, 10)),
Expand Down Expand Up @@ -50,6 +53,7 @@ export const getPublishers = async (cluster: Cluster) =>
timestamp,
publisher AS key,
rank,
LENGTH(symbols) AS permissionedFeeds,
activeFeeds,
inactiveFeeds,
score_data.averageScore,
Expand Down