avoid db dip for sub

This commit is contained in:
keyan 2023-05-05 12:38:56 -05:00
parent 7e0103bce3
commit b406f0c340
11 changed files with 16 additions and 22 deletions

View File

@ -118,6 +118,7 @@ export default gql`
location: String location: String
remote: Boolean remote: Boolean
sub: Sub sub: Sub
subName: String
status: String status: String
uploadId: Int uploadId: Int
otsHash: String otsHash: String

View File

@ -62,7 +62,7 @@ export function BountyForm ({
(async ({ boost, bounty, ...values }) => { (async ({ boost, bounty, ...values }) => {
const { error } = await upsertBounty({ const { error } = await upsertBounty({
variables: { variables: {
sub: item?.sub?.name || sub?.name, sub: item?.subName || sub?.name,
id: item?.id, id: item?.id,
boost: boost ? Number(boost) : undefined, boost: boost ? Number(boost) : undefined,
bounty: bounty ? Number(bounty) : undefined, bounty: bounty ? Number(bounty) : undefined,

View File

@ -41,9 +41,9 @@ function Parent ({ item, rootText }) {
<Link href={`/items/${item.root.id}`} passHref> <Link href={`/items/${item.root.id}`} passHref>
<a className='text-reset'>{rootText || 'on:'} {item.root.title}</a> <a className='text-reset'>{rootText || 'on:'} {item.root.title}</a>
</Link> </Link>
{item.root.sub?.name && {item.root.subName &&
<Link href={`/~${item.root.sub?.name}`}> <Link href={`/~${item.root.subName}`}>
<a>{' '}<Badge className={itemStyles.newComment} variant={null}>{item.root.sub?.name}</Badge></a> <a>{' '}<Badge className={itemStyles.newComment} variant={null}>{item.root.subName}</Badge></a>
</Link>} </Link>}
</> </>
) )

View File

@ -56,7 +56,7 @@ export function DiscussionForm ({
schema={schema} schema={schema}
onSubmit={handleSubmit || (async ({ boost, ...values }) => { onSubmit={handleSubmit || (async ({ boost, ...values }) => {
const { error } = await upsertDiscussion({ const { error } = await upsertDiscussion({
variables: { sub: item?.sub?.name || sub?.name, id: item?.id, boost: boost ? Number(boost) : undefined, ...values } variables: { sub: item?.subName || sub?.name, id: item?.id, boost: boost ? Number(boost) : undefined, ...values }
}) })
if (error) { if (error) {
throw new Error({ message: error.toString() }) throw new Error({ message: error.toString() })

View File

@ -65,9 +65,9 @@ export default function ItemInfo ({ item, commentsText, className, embellishUser
</Link> </Link>
</>} </>}
</span> </span>
{item.sub?.name && {item.subName &&
<Link href={`/~${item.sub?.name}`}> <Link href={`/~${item.subName}`}>
<a>{' '}<Badge className={styles.newComment} variant={null}>{item.sub?.name}</Badge></a> <a>{' '}<Badge className={styles.newComment} variant={null}>{item.subName}</Badge></a>
</Link>} </Link>}
{(item.outlawed && !item.mine && {(item.outlawed && !item.mine &&
<Link href='/outlawed'> <Link href='/outlawed'>

View File

@ -85,7 +85,7 @@ export function LinkForm ({ item, sub, editThreshold }) {
schema={schema} schema={schema}
onSubmit={async ({ boost, title, ...values }) => { onSubmit={async ({ boost, title, ...values }) => {
const { error } = await upsertLink({ const { error } = await upsertLink({
variables: { sub: item?.sub?.name || sub?.name, id: item?.id, boost: boost ? Number(boost) : undefined, title: title.trim(), ...values } variables: { sub: item?.subName || sub?.name, id: item?.id, boost: boost ? Number(boost) : undefined, title: title.trim(), ...values }
}) })
if (error) { if (error) {
throw new Error({ message: error.toString() }) throw new Error({ message: error.toString() })

View File

@ -42,7 +42,7 @@ export function PollForm ({ item, sub, editThreshold }) {
const { error } = await upsertPoll({ const { error } = await upsertPoll({
variables: { variables: {
id: item?.id, id: item?.id,
sub: item?.sub?.name || sub?.name, sub: item?.subName || sub?.name,
boost: boost ? Number(boost) : undefined, boost: boost ? Number(boost) : undefined,
title: title.trim(), title: title.trim(),
options: optionsFiltered, options: optionsFiltered,

View File

@ -31,9 +31,7 @@ export const COMMENT_FIELDS = gql`
title title
bounty bounty
bountyPaidTo bountyPaidTo
sub { subName
name
}
user { user {
name name
streak streak

View File

@ -37,10 +37,7 @@ export const ITEM_FIELDS = gql`
company company
location location
remote remote
sub { subName
name
baseCost
}
pollCost pollCost
status status
uploadId uploadId
@ -63,9 +60,7 @@ export const ITEM_FULL_FIELDS = gql`
title title
bounty bounty
bountyPaidTo bountyPaidTo
sub { subName
name
}
user { user {
name name
streak streak

View File

@ -14,7 +14,7 @@ export default function PostEdit ({ data: { item } }) {
const editThreshold = new Date(item.createdAt).getTime() + 10 * 60000 const editThreshold = new Date(item.createdAt).getTime() + 10 * 60000
return ( return (
<LayoutCenter sub={item.sub?.name}> <LayoutCenter sub={item.subName}>
{item.isJob {item.isJob
? <JobForm item={item} sub={item.sub} /> ? <JobForm item={item} sub={item.sub} />
: (item.url : (item.url

View File

@ -16,7 +16,7 @@ export default function AnItem ({ data: { item } }) {
({ item } = data) ({ item } = data)
} }
const sub = item.sub?.name || item.root?.sub?.name const sub = item.subName || item.root?.subName
return ( return (
<Layout sub={sub} noSeo> <Layout sub={sub} noSeo>