fix: CNX-7606 Fixes missing `Data` column error (#61)
* fix: Result will now include parent commit object and no longer assume it will have children * fix: Keep metadata in joined table
This commit is contained in:
Родитель
95f51b0d32
Коммит
c752487f9f
|
@ -1,5 +1,6 @@
|
|||
let
|
||||
Fetch = Extension.LoadFunction("Api.Fetch.pqm"),
|
||||
GetObject = Extension.LoadFunction("Api.GetObject.pqm"),
|
||||
GetAllObjectChildren = Extension.LoadFunction("Api.GetAllObjectChildren.pqm"),
|
||||
GetObjectFromCommit = Extension.LoadFunction("GetObjectFromCommit.pqm"),
|
||||
GetObjectFromBranch = Extension.LoadFunction("GetObjectFromBranch.pqm"),
|
||||
|
@ -34,8 +35,7 @@ in
|
|||
GetObjectFromBranch(server, id, stream[branch])
|
||||
else
|
||||
GetObjectFromBranch(server, id, "main"),
|
||||
removeEmpty = Table.RemoveLastN(commitObjectsTable, 1),
|
||||
addStreamUrl = Table.AddColumn(removeEmpty, "Stream URL", each server & "/streams/" & id),
|
||||
addStreamUrl = Table.AddColumn(commitObjectsTable, "Stream URL", each server & "/streams/" & id),
|
||||
addParentObjectId = Table.AddColumn(
|
||||
addStreamUrl, "Commit Object ID", each Value.Metadata(commitObjectsTable)[objectId]
|
||||
),
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
let
|
||||
Table.GenerateByPage = Extension.LoadFunction("Table.GenerateByPage.pqm"),
|
||||
Speckle.Api.GetObjectChildren = Extension.LoadFunction("Api.GetObjectChildren.pqm"),
|
||||
Speckle.Api.GetObject = Extension.LoadFunction("Api.GetObject.pqm"),
|
||||
Extension.LoadFunction = (fileName as text) =>
|
||||
let
|
||||
binary = Extension.Contents(fileName), asText = Text.FromBinary(binary)
|
||||
|
@ -19,17 +20,27 @@ in
|
|||
// After every page, we check the "nextCursor" record on the metadata of the previous request.
|
||||
// Table.GenerateByPage will keep asking for more pages until we return null.
|
||||
(server as text, streamId as text, objectId as text, optional cursor as text) as table =>
|
||||
Table.GenerateByPage(
|
||||
(previous) =>
|
||||
let
|
||||
// if previous is null, then this is our first page of data
|
||||
nextCursor = if (previous = null) then cursor else Value.Metadata(previous)[Cursor]?,
|
||||
// if the cursor is null but the prevous page is not, we've reached the end
|
||||
page =
|
||||
if (previous <> null and nextCursor = null) then
|
||||
null
|
||||
else
|
||||
Speckle.Api.GetObjectChildren(server, streamId, objectId, 1000, nextCursor)
|
||||
in
|
||||
page
|
||||
) meta [server = server, streamId = streamId, objectId = objectId]
|
||||
let
|
||||
parentObject = Speckle.Api.GetObject(server, streamId, objectId),
|
||||
childrenTable = Table.GenerateByPage(
|
||||
(previous) =>
|
||||
let
|
||||
// if previous is null, then this is our first page of data
|
||||
nextCursor = if (previous = null) then cursor else Value.Metadata(previous)[Cursor]?,
|
||||
// if the cursor is null but the prevous page is not, we've reached the end
|
||||
page =
|
||||
if (previous <> null and nextCursor = null) then
|
||||
null
|
||||
else
|
||||
Speckle.Api.GetObjectChildren(server, streamId, objectId, 1000, nextCursor)
|
||||
in
|
||||
page
|
||||
),
|
||||
parentTable = Table.FromRecords({[data = parentObject]}),
|
||||
resultTable =
|
||||
if (Table.ColumnCount(childrenTable) = 0) then
|
||||
parentTable
|
||||
else
|
||||
Table.Combine({parentTable, childrenTable})
|
||||
in
|
||||
resultTable meta [server = server, streamId = streamId, objectId = objectId]
|
||||
|
|
|
@ -14,4 +14,4 @@
|
|||
),
|
||||
removed = List.Select(removeTotals, each _[data][speckle_type] <> "Speckle.Core.Models.DataChunk")
|
||||
in
|
||||
removed
|
||||
try removed otherwise objects
|
||||
|
|
Загрузка…
Ссылка в новой задаче