Skip to content

Commit

Permalink
Merge pull request #2406 from specklesystems/dim/objs-fixes
Browse files Browse the repository at this point in the history
fix(objects): wip fix on getObjectChildren in post closure world
  • Loading branch information
didimitrie authored Jun 19, 2024
2 parents 5f1b384 + 77d49a1 commit 63c2d09
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/server/modules/core/graph/resolvers/objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = {
})
result.objects.forEach((x) => (x.streamId = parent.streamId))
return {
totalCount: parent.totalChildrenCount,
totalCount: parent.totalChildrenCount || '0',
cursor: result.cursor,
objects: result.objects
}
Expand Down
24 changes: 18 additions & 6 deletions packages/server/modules/core/services/objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,16 @@ module.exports = {

let fullObjectSelect = false

const q = Closures()
q.select('id')
q.select('createdAt')
q.select('speckleType')
q.select('totalChildrenCount')
const q = knex.with(
'object_children_closure',
knex.raw(
`SELECT objects.id as parent, d.key as child, d.value as minDepth, ? as "streamId"
FROM objects
JOIN jsonb_each_text(objects.data->'__closure') d ON true
where objects.id = ?`,
[streamId, objectId]
)
)

if (Array.isArray(select)) {
select.forEach((field, index) => {
Expand All @@ -303,6 +308,13 @@ module.exports = {
q.select('data')
}

q.select('id')
q.select('createdAt')
q.select('speckleType')
q.select('totalChildrenCount')

q.from('object_children_closure')

q.rightJoin('objects', function () {
this.on('objects.streamId', '=', 'object_children_closure.streamId').andOn(
'objects.id',
Expand All @@ -316,7 +328,7 @@ module.exports = {
objectId
])
)
.andWhere(knex.raw('"minDepth" < ?', [depth]))
.andWhere(knex.raw('object_children_closure."mindepth" < ?', [depth]))
.andWhere(knex.raw('id > ?', [cursor ? cursor : '0']))
.orderBy('objects.id')
.limit(limit)
Expand Down

0 comments on commit 63c2d09

Please sign in to comment.