datajunction-ui 0.0.96 → 0.0.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1305,6 +1305,28 @@ export const DataJunctionAPI = {
|
|
|
1305
1305
|
if (results.state === 'FAILED') {
|
|
1306
1306
|
throw new Error(results.errors?.[0] || 'Query execution failed');
|
|
1307
1307
|
}
|
|
1308
|
+
|
|
1309
|
+
// If FINISHED but results are empty, re-submit to /data/ a few times
|
|
1310
|
+
// before giving up (mirrors the Python client's behavior).
|
|
1311
|
+
if (!results.results?.length || !results.results[0]?.rows?.length) {
|
|
1312
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
1313
|
+
await sleep(2 ** attempt * 1000);
|
|
1314
|
+
const retryResponse = await fetch(`${DJ_URL}/data/?${params}`, {
|
|
1315
|
+
credentials: 'include',
|
|
1316
|
+
});
|
|
1317
|
+
if (retryResponse.ok) {
|
|
1318
|
+
const retryResults = await retryResponse.json();
|
|
1319
|
+
if (
|
|
1320
|
+
retryResults.results?.length &&
|
|
1321
|
+
retryResults.results[0]?.rows?.length
|
|
1322
|
+
) {
|
|
1323
|
+
results = retryResults;
|
|
1324
|
+
break;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1308
1330
|
return results;
|
|
1309
1331
|
},
|
|
1310
1332
|
|
|
@@ -619,7 +619,12 @@ describe('DataJunctionAPI', () => {
|
|
|
619
619
|
it('calls data correctly', async () => {
|
|
620
620
|
const metricSelection = ['metric1'];
|
|
621
621
|
const dimensionSelection = ['dimension1'];
|
|
622
|
-
fetch.mockResponseOnce(
|
|
622
|
+
fetch.mockResponseOnce(
|
|
623
|
+
JSON.stringify({
|
|
624
|
+
state: 'FINISHED',
|
|
625
|
+
results: [{ rows: [['val']] }],
|
|
626
|
+
}),
|
|
627
|
+
);
|
|
623
628
|
await DataJunctionAPI.data(metricSelection, dimensionSelection);
|
|
624
629
|
expect(fetch).toHaveBeenCalledWith(
|
|
625
630
|
expect.stringContaining(`${DJ_URL}/data/?`),
|
|
@@ -3004,7 +3009,11 @@ describe('DataJunctionAPI', () => {
|
|
|
3004
3009
|
it('calls data with filters array', async () => {
|
|
3005
3010
|
fetch.mockResolvedValueOnce({
|
|
3006
3011
|
ok: true,
|
|
3007
|
-
json: () =>
|
|
3012
|
+
json: () =>
|
|
3013
|
+
Promise.resolve({
|
|
3014
|
+
state: 'FINISHED',
|
|
3015
|
+
results: [{ rows: [['val']] }],
|
|
3016
|
+
}),
|
|
3008
3017
|
});
|
|
3009
3018
|
await DataJunctionAPI.data(
|
|
3010
3019
|
['metric1'],
|