Fixed setup save queries within serverless accounts (#1626)

* Fixed setup save queries within serverless accounts

* Fixed format

* ran prettier
This commit is contained in:
JustinKol 2023-10-04 14:23:22 -04:00 committed by GitHub
parent 68b45e77a8
commit 07d242f972
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 20 deletions

View File

@ -13,6 +13,7 @@ import { createDocument } from "./dataAccess/createDocument";
import { deleteDocument } from "./dataAccess/deleteDocument";
import { queryDocuments } from "./dataAccess/queryDocuments";
import { handleError } from "./ErrorHandlingUtils";
import { isServerlessAccount } from "Utils/CapabilityUtils";
export class QueriesClient {
private static readonly PartitionKey: DataModels.PartitionKey = {
@ -32,25 +33,36 @@ export class QueriesClient {
}
const clearMessage = NotificationConsoleUtils.logConsoleProgress("Setting up account for saving queries");
return createCollection({
collectionId: SavedQueries.CollectionName,
createNewDatabase: true,
databaseId: SavedQueries.DatabaseName,
partitionKey: QueriesClient.PartitionKey,
offerThroughput: SavedQueries.OfferThroughput,
databaseLevelThroughput: false,
})
.then(
(collection: DataModels.Collection) => {
NotificationConsoleUtils.logConsoleInfo("Successfully set up account for saving queries");
return Promise.resolve(collection);
},
(error: any) => {
handleError(error, "setupQueriesCollection", "Failed to set up account for saving queries");
return Promise.reject(error);
},
)
.finally(() => clearMessage());
if (isServerlessAccount()) {
return createCollection({
collectionId: SavedQueries.CollectionName,
createNewDatabase: true,
databaseId: SavedQueries.DatabaseName,
partitionKey: QueriesClient.PartitionKey,
databaseLevelThroughput: false,
});
} else {
return createCollection({
collectionId: SavedQueries.CollectionName,
createNewDatabase: true,
databaseId: SavedQueries.DatabaseName,
partitionKey: QueriesClient.PartitionKey,
offerThroughput: SavedQueries.OfferThroughput,
databaseLevelThroughput: false,
})
.then(
(collection: DataModels.Collection) => {
NotificationConsoleUtils.logConsoleInfo("Successfully set up account for saving queries");
return Promise.resolve(collection);
},
(error: any) => {
handleError(error, "setupQueriesCollection", "Failed to set up account for saving queries");
return Promise.reject(error);
},
)
.finally(() => clearMessage());
}
}
public async saveQuery(query: DataModels.Query): Promise<void> {

View File

@ -318,7 +318,7 @@ export interface CreateCollectionParams {
collectionId: string;
databaseId: string;
databaseLevelThroughput: boolean;
offerThroughput: number;
offerThroughput?: number;
analyticalStorageTtl?: number;
autoPilotMaxThroughput?: number;
indexingPolicy?: IndexingPolicy;

View File

@ -113,6 +113,7 @@ export const SaveQueryPane: FunctionComponent<SaveQueryPaneProps> = ({
},
startKey,
);
closeSidePanel();
} catch (error) {
const errorMessage = getErrorMessage(error);
traceFailure(