Skip to content

Commit 1712c13

Browse files
committed
fix(insights): implement pr feedback
1 parent 07bd973 commit 1712c13

File tree

4 files changed

+30
-43
lines changed

4 files changed

+30
-43
lines changed

apps/insights/src/components/Publisher/performance.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const Performance = async ({ params }: Props) => {
6363
prefetch: false,
6464
nameAsString: knownPublisher?.name ?? publisher.key,
6565
data: {
66-
ranking: (
66+
ranking: (publisher.rank !== undefined || publisher.key === key) && (
6767
<Ranking isCurrent={publisher.key === key} className={styles.ranking}>
6868
{publisher.rank}
6969
</Ranking>
@@ -86,14 +86,9 @@ export const Performance = async ({ params }: Props) => {
8686
{publisher.inactiveFeeds}
8787
</Link>
8888
),
89-
averageScore:
90-
// eslint-disable-next-line unicorn/no-null
91-
publisher.averageScore === undefined ? null : (
92-
<Score
93-
width={PUBLISHER_SCORE_WIDTH}
94-
score={publisher.averageScore}
95-
/>
96-
),
89+
averageScore: publisher.averageScore !== undefined && (
90+
<Score width={PUBLISHER_SCORE_WIDTH} score={publisher.averageScore} />
91+
),
9792
name: (
9893
<PublisherTag
9994
cluster={parsedCluster}

apps/insights/src/components/Publishers/publishers-card.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,7 @@ const ResolvedPublishersCard = ({
155155
textValue: publisher.name ?? id,
156156
prefetch: false,
157157
data: {
158-
ranking:
159-
// eslint-disable-next-line unicorn/no-null
160-
ranking === undefined ? null : <Ranking>{ranking}</Ranking>,
158+
ranking: ranking !== undefined && <Ranking>{ranking}</Ranking>,
161159
name: (
162160
<PublisherTag
163161
publisherKey={id}
@@ -177,11 +175,9 @@ const ResolvedPublishersCard = ({
177175
{activeFeeds}
178176
</Link>
179177
),
180-
averageScore:
181-
// eslint-disable-next-line unicorn/no-null
182-
averageScore === undefined ? null : (
183-
<Score score={averageScore} width={PUBLISHER_SCORE_WIDTH} />
184-
),
178+
averageScore: averageScore !== undefined && (
179+
<Score score={averageScore} width={PUBLISHER_SCORE_WIDTH} />
180+
),
185181
},
186182
}),
187183
),

apps/insights/src/components/Root/search-button.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -291,12 +291,9 @@ const SearchDialogContents = ({
291291
<>
292292
<dt>Average Score</dt>
293293
<dd>
294-
{
295-
// eslint-disable-next-line unicorn/no-null
296-
result.averageScore === undefined ? null : (
297-
<Score score={result.averageScore} />
298-
)
299-
}
294+
{result.averageScore !== undefined && (
295+
<Score score={result.averageScore} />
296+
)}
300297
</dd>
301298
</>
302299
)}
@@ -340,12 +337,9 @@ const SearchDialogContents = ({
340337
icon: result.icon,
341338
})}
342339
/>
343-
{
344-
// eslint-disable-next-line unicorn/no-null
345-
result.averageScore === undefined ? null : (
346-
<Score score={result.averageScore} />
347-
)
348-
}
340+
{result.averageScore !== undefined && (
341+
<Score score={result.averageScore} />
342+
)}
349343
</>
350344
)}
351345
</div>

apps/insights/src/services/pyth/get-publishers-for-cluster.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,29 @@ import { redisCache } from "../../cache";
55
const _getPublishersByFeedForCluster = async (cluster: Cluster) => {
66
const data = await getPythMetadata(cluster);
77
const result: Record<string, string[]> = {};
8-
for (const key of data.productPrice.keys()) {
9-
const price = data.productPrice.get(key);
10-
result[key] =
11-
price?.priceComponents.map(({ publisher }) => publisher.toBase58()) ?? [];
8+
for (const [key, price] of data.productPrice.entries()) {
9+
result[key] = price.priceComponents.map(({ publisher }) =>
10+
publisher.toBase58(),
11+
);
1212
}
1313
return result;
1414
};
1515

16+
/**
17+
* Given a cluster, this function will return a record which maps each
18+
* permissioned publisher to the list of price feed IDs for which that publisher
19+
* is permissioned.
20+
*/
1621
const _getFeedsByPublisherForCluster = async (cluster: Cluster) => {
1722
const data = await getPythMetadata(cluster);
1823
const result: Record<string, string[]> = {};
19-
for (const symbol of data.productPrice.keys()) {
20-
const price = data.productPrice.get(symbol);
21-
if (price !== undefined) {
22-
for (const component of price.priceComponents) {
23-
const publisherKey = component.publisher.toBase58();
24-
if (result[publisherKey] === undefined) {
25-
result[publisherKey] = [symbol];
26-
} else {
27-
result[publisherKey].push(symbol);
28-
}
24+
for (const [symbol, price] of data.productPrice.entries()) {
25+
for (const component of price.priceComponents) {
26+
const publisherKey = component.publisher.toBase58();
27+
if (result[publisherKey] === undefined) {
28+
result[publisherKey] = [symbol];
29+
} else {
30+
result[publisherKey].push(symbol);
2931
}
3032
}
3133
}

0 commit comments

Comments
 (0)