Fix query for items with less than 11 parents (#346)
Co-authored-by: ekzyis <ek@stacker.news>
This commit is contained in:
parent
e0d89a289b
commit
46014d0de4
|
@ -34,8 +34,8 @@ const createUserFilter = (tag) => {
|
|||
|
||||
const createItemUrl = async ({ id }) => {
|
||||
const [rootItem] = await models.$queryRaw(
|
||||
'SELECT subpath(path, $1, 1)::text AS id FROM "Item" WHERE id = $2',
|
||||
-(COMMENT_DEPTH_LIMIT + 1), Number(id)
|
||||
'SELECT subpath(path, -LEAST(nlevel(path), $1), 1)::text AS id FROM "Item" WHERE id = $2',
|
||||
COMMENT_DEPTH_LIMIT + 1, Number(id)
|
||||
)
|
||||
return `/items/${rootItem.id}` + (rootItem.id !== id ? `?commentId=${id}` : '')
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue