Skip to content

Commit

Permalink
fix full path regression
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminpkane committed Sep 23, 2024
1 parent d1a1153 commit 0605b14
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
30 changes: 28 additions & 2 deletions app/packages/looker/src/elements/common/bubbles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
DYNAMIC_EMBEDDED_DOCUMENT_PATH,
EMBEDDED_DOCUMENT_FIELD,
LIST_FIELD,
STRING_FIELD,
} from "@fiftyone/utilities";
import { getBubbles, getField, unwind } from "./bubbles";

Expand All @@ -28,7 +29,7 @@ describe("text bubble tests", () => {
});

it("getBubble gets values for path", () => {
const field = {
const listField = {
...FIELD_DATA,
dbField: "my",
ftype: LIST_FIELD,
Expand All @@ -44,13 +45,38 @@ describe("text bubble tests", () => {
getBubbles(
"my",
{ my: [{ list: "value" }] },
{
my: {
...listField,
},
}
)
).toStrictEqual([listField, [{ list: "value" }]]);

const field = {
...FIELD_DATA,
dbField: "my",
ftype: EMBEDDED_DOCUMENT_FIELD,
embeddedDocType: DYNAMIC_EMBEDDED_DOCUMENT_PATH,
fields: {
value: {
...FIELD_DATA,
dbField: "value",
ftype: STRING_FIELD,
},
},
};
expect(
getBubbles(
"my.value",
{ my: { value: "value" } },
{
my: {
...field,
},
}
)
).toStrictEqual([field, [{ list: "value" }]]);
).toStrictEqual([field.fields.value, ["value"]]);
});

it("getField gets field from a path keys", () => {
Expand Down
6 changes: 3 additions & 3 deletions app/packages/looker/src/elements/common/bubbles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ type Data = { [key: string]: unknown };

export const getBubbles = (
path: string,
sample: Data,
data: Data,
input: Schema
): [Field, unknown[]] => {
const out = parseSample(path.split("."), sample, input);
const out = parseSample(path.split("."), data, input);

let field: Field = null;
for (const key of out.keys.slice(0, 2)) {
Expand Down Expand Up @@ -69,7 +69,7 @@ export const getBubbles = (

if (out.values?.length && field) {
out.values = unwind(field.dbField, out.values) || [];
break;
console.log(path, out.values);
}

out.schema = field ? field.fields : null;
Expand Down

0 comments on commit 0605b14

Please sign in to comment.