fix fragment when comment visited directly + one db dip
This commit is contained in:
		
							parent
							
								
									65b1db23a7
								
							
						
					
					
						commit
						ed9fa5f823
					
				| @ -20,21 +20,12 @@ export async function getBaseCost ({ models, bio, parentId, subName }) { | ||||
| 
 | ||||
|   if (parentId) { | ||||
|     // the subname is stored in the root item of the thread
 | ||||
|     const parent = await models.item.findFirst({ | ||||
|       where: { id: Number(parentId) }, | ||||
|       include: { | ||||
|         root: { include: { sub: true } }, | ||||
|         sub: true | ||||
|       } | ||||
|     }) | ||||
| 
 | ||||
|     const root = parent.root ?? parent | ||||
| 
 | ||||
|     // XXX Prisma does not support case-insensitive joins on CITEXT column
 | ||||
|     // so we fetch the territory in a separate query
 | ||||
|     const sub = await models.sub.findUnique({ | ||||
|       where: { name: root.subName } | ||||
|     }) | ||||
|     const [sub] = await models.$queryRaw` | ||||
|       SELECT s."replyCost" | ||||
|       FROM "Item" i | ||||
|       LEFT JOIN "Item" r ON r.id = i."rootId" | ||||
|       LEFT JOIN "Sub" s ON s.name = COALESCE(r."subName", i."subName") | ||||
|       WHERE i.id = ${Number(parentId)}` | ||||
| 
 | ||||
|     if (!sub) return DEFAULT_ITEM_COST | ||||
|     return satsToMsats(sub.replyCost) | ||||
|  | ||||
| @ -108,6 +108,7 @@ export const ITEM_FULL_FIELDS = gql` | ||||
|         moderated | ||||
|         meMuteSub | ||||
|         meSubscription | ||||
|         replyCost | ||||
|       } | ||||
|     } | ||||
|     forwards { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user