Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSDK-5477 - clearer tabular data objects #185

4 changes: 2 additions & 2 deletions src/app/data-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ describe('DataClient tests', () => {
const promise = await subject().tabularDataByFilter();
expect(promise.length).toEqual(2);
const [data1, data2] = promise;
expect(data1).toMatchObject(tabData1.toObject());
expect(data2).toMatchObject(tabData2.toObject());
expect(data1).toMatchObject(tabData1.getData().toJavaScript());
expect(data2).toMatchObject(tabData2.getData().toJavaScript());
});

test('get filtered tabular data', async () => {
Expand Down
22 changes: 16 additions & 6 deletions src/app/data-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type FilterOptions = Partial<pb.Filter.AsObject> & {

type TabularData = {
data?: googleStructPb.Struct.AsObject;
purplenicole730 marked this conversation as resolved.
Show resolved Hide resolved
metadataIndex: number;
metadata?: pb.CaptureMetadata.AsObject;
timeRequested?: Date;
timeReceived?: Date;
};
Expand Down Expand Up @@ -53,11 +53,21 @@ export class DataClient {
break;
}
dataArray.push(
...dataList.map((data) => ({
...data.toObject(),
timeRequested: data.getTimeRequested()?.toDate(),
timeReceived: data.getTimeReceived()?.toDate(),
}))
...dataList.map((data) => {
const mdIndex = data.getMetadataIndex();
const mdListLength = response.getMetadataList().length;
purplenicole730 marked this conversation as resolved.
Show resolved Hide resolved
if (mdListLength != 0 && mdIndex >= mdListLength) {
throw Error(
purplenicole730 marked this conversation as resolved.
Show resolved Hide resolved
`metadata index ${mdIndex} is out of response's metadata list`
);
}
return {
...data.getData()?.toJavaScript(),
purplenicole730 marked this conversation as resolved.
Show resolved Hide resolved
metadata: response.getMetadataList()[mdIndex]?.toObject(),
timeRequested: data.getTimeRequested()?.toDate(),
timeReceived: data.getTimeReceived()?.toDate(),
};
})
);
last = response.getLast();
}
Expand Down