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 let
Fetch = Extension.LoadFunction("Api.Fetch.pqm"), Fetch = Extension.LoadFunction("Api.Fetch.pqm"),
GetObject = Extension.LoadFunction("Api.GetObject.pqm"),
GetAllObjectChildren = Extension.LoadFunction("Api.GetAllObjectChildren.pqm"), GetAllObjectChildren = Extension.LoadFunction("Api.GetAllObjectChildren.pqm"),
GetObjectFromCommit = Extension.LoadFunction("GetObjectFromCommit.pqm"), GetObjectFromCommit = Extension.LoadFunction("GetObjectFromCommit.pqm"),
GetObjectFromBranch = Extension.LoadFunction("GetObjectFromBranch.pqm"), GetObjectFromBranch = Extension.LoadFunction("GetObjectFromBranch.pqm"),
@ -34,8 +35,7 @@ in
GetObjectFromBranch(server, id, stream[branch]) GetObjectFromBranch(server, id, stream[branch])
else else
GetObjectFromBranch(server, id, "main"), GetObjectFromBranch(server, id, "main"),
removeEmpty = Table.RemoveLastN(commitObjectsTable, 1), addStreamUrl = Table.AddColumn(commitObjectsTable, "Stream URL", each server & "/streams/" & id),
addStreamUrl = Table.AddColumn(removeEmpty, "Stream URL", each server & "/streams/" & id),
addParentObjectId = Table.AddColumn( addParentObjectId = Table.AddColumn(
addStreamUrl, "Commit Object ID", each Value.Metadata(commitObjectsTable)[objectId] addStreamUrl, "Commit Object ID", each Value.Metadata(commitObjectsTable)[objectId]
), ),

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

@ -1,6 +1,7 @@
let let
Table.GenerateByPage = Extension.LoadFunction("Table.GenerateByPage.pqm"), Table.GenerateByPage = Extension.LoadFunction("Table.GenerateByPage.pqm"),
Speckle.Api.GetObjectChildren = Extension.LoadFunction("Api.GetObjectChildren.pqm"), Speckle.Api.GetObjectChildren = Extension.LoadFunction("Api.GetObjectChildren.pqm"),
Speckle.Api.GetObject = Extension.LoadFunction("Api.GetObject.pqm"),
Extension.LoadFunction = (fileName as text) => Extension.LoadFunction = (fileName as text) =>
let let
binary = Extension.Contents(fileName), asText = Text.FromBinary(binary) 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. // 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. // 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 => (server as text, streamId as text, objectId as text, optional cursor as text) as table =>
Table.GenerateByPage( let
(previous) => parentObject = Speckle.Api.GetObject(server, streamId, objectId),
let childrenTable = Table.GenerateByPage(
// if previous is null, then this is our first page of data (previous) =>
nextCursor = if (previous = null) then cursor else Value.Metadata(previous)[Cursor]?, let
// if the cursor is null but the prevous page is not, we've reached the end // if previous is null, then this is our first page of data
page = nextCursor = if (previous = null) then cursor else Value.Metadata(previous)[Cursor]?,
if (previous <> null and nextCursor = null) then // if the cursor is null but the prevous page is not, we've reached the end
null page =
else if (previous <> null and nextCursor = null) then
Speckle.Api.GetObjectChildren(server, streamId, objectId, 1000, nextCursor) null
in else
page Speckle.Api.GetObjectChildren(server, streamId, objectId, 1000, nextCursor)
) meta [server = server, streamId = streamId, objectId = objectId] 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") removed = List.Select(removeTotals, each _[data][speckle_type] <> "Speckle.Core.Models.DataChunk")
in in
removed try removed otherwise objects