mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-10-13 23:38:45 +01:00
26 lines
1.0 KiB
TypeScript
26 lines
1.0 KiB
TypeScript
import { client } from "../CosmosClient";
|
|
import { handleError } from "../ErrorHandlingUtils";
|
|
import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
|
import * as Constants from "../Constants";
|
|
import { AuthType } from "../../AuthType";
|
|
|
|
export async function getIndexTransformationProgress(databaseId: string, collectionId: string): Promise<number> {
|
|
if (window.authType !== AuthType.AAD) {
|
|
return undefined;
|
|
}
|
|
let indexTransformationPercentage: number;
|
|
const clearMessage = logConsoleProgress(`Reading container ${collectionId}`);
|
|
try {
|
|
const response = await client().database(databaseId).container(collectionId).read({ populateQuotaInfo: true });
|
|
|
|
indexTransformationPercentage = parseInt(
|
|
response.headers[Constants.HttpHeaders.collectionIndexTransformationProgress] as string
|
|
);
|
|
} catch (error) {
|
|
handleError(error, "ReadMongoDBCollection", `Error while reading container ${collectionId}`);
|
|
throw error;
|
|
}
|
|
clearMessage();
|
|
return indexTransformationPercentage;
|
|
}
|