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:
Alan Rynne 2024-01-12 13:29:42 +01:00 коммит произвёл GitHub
Родитель 95f51b0d32
Коммит c752487f9f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 28 добавлений и 17 удалений

Просмотреть файл

@ -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,7 +20,9 @@ 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(
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
@ -32,4 +35,12 @@ in
Speckle.Api.GetObjectChildren(server, streamId, objectId, 1000, nextCursor)
in
page
) meta [server = server, streamId = streamId, objectId = objectId]
),
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