fix bad earn link it satistics

This commit is contained in:
keyan 2022-08-18 15:57:48 -05:00
parent 4d444d1286
commit 03723bd5ee
2 changed files with 20 additions and 12 deletions

View File

@ -14,6 +14,7 @@ import { Checkbox, Form } from '../components/form'
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
import Item from '../components/item' import Item from '../components/item'
import Comment from '../components/comment' import Comment from '../components/comment'
import React from 'react'
export const getServerSideProps = getGetServerSideProps(WALLET_HISTORY) export const getServerSideProps = getGetServerSideProps(WALLET_HISTORY)
@ -142,6 +143,8 @@ export default function Satistics ({ data: { me, walletHistory: { facts, cursor
case 'withdrawal': case 'withdrawal':
case 'invoice': case 'invoice':
return `/${fact.type}s/${fact.factId}` return `/${fact.type}s/${fact.factId}`
case 'earn':
return
default: default:
return `/items/${fact.factId}` return `/items/${fact.factId}`
} }
@ -200,17 +203,22 @@ export default function Satistics ({ data: { me, walletHistory: { facts, cursor
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{facts.map((f, i) => ( {facts.map((f, i) => {
<Link href={href(f)} key={f.id}> const uri = href(f)
<tr className={styles.row}> const Wrapper = uri ? Link : React.Fragment
<td className={`${styles.type} ${satusClass(f.status)}`}>{f.type}</td>
<td className={styles.description}> return (
<Detail fact={f} /> <Wrapper href={uri} key={f.id}>
</td> <tr className={styles.row}>
<td className={`${styles.sats} ${satusClass(f.status)}`}>{f.msats / 1000}</td> <td className={`${styles.type} ${satusClass(f.status)}`}>{f.type}</td>
</tr> <td className={styles.description}>
</Link> <Detail fact={f} />
))} </td>
<td className={`${styles.sats} ${satusClass(f.status)}`}>{Math.floor(f.msats / 1000)}</td>
</tr>
</Wrapper>
)
})}
</tbody> </tbody>
</Table> </Table>
<MoreFooter cursor={cursor} fetchMore={fetchMore} Skeleton={SatisticsSkeleton} /> <MoreFooter cursor={cursor} fetchMore={fetchMore} Skeleton={SatisticsSkeleton} />

View File

@ -34,7 +34,7 @@ function earn ({ models }) {
const earners = await models.$queryRaw(` const earners = await models.$queryRaw(`
WITH item_ratios AS ( WITH item_ratios AS (
SELECT *, SELECT *,
"weightedVotes"/(sum("weightedVotes") OVER (PARTITION BY "parentId" IS NULL)) AS ratio "weightedVotes"/coalesce(NULLIF(sum("weightedVotes") OVER (PARTITION BY "parentId" IS NULL),0), ${TOP_ITEMS}) AS ratio
FROM ( FROM (
SELECT *, SELECT *,
ROW_NUMBER() OVER (PARTITION BY "parentId" IS NULL ORDER BY "weightedVotes" desc) AS r ROW_NUMBER() OVER (PARTITION BY "parentId" IS NULL ORDER BY "weightedVotes" desc) AS r