mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 15:06:55 +00:00
Remove database offers cache and get offer directly from database (#268)
Currently we maintain a cache of all database offers which can be stale since we have moved to lazy loading the offers. Instead of reading the offer from the cache, we should just find the selected database and get the offer directly by calling `database.offer()`.
This commit is contained in:
parent
88d630fef4
commit
a698e08638
@ -84,9 +84,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"visible": [Function],
|
||||
},
|
||||
AddCollectionPane {
|
||||
"_databaseOffers": HashMap {
|
||||
"container": Object {},
|
||||
},
|
||||
"_isSynapseLinkEnabled": [Function],
|
||||
"autoPilotThroughput": [Function],
|
||||
"autoPilotTiersList": [Function],
|
||||
@ -586,9 +583,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"_refreshSparkEnabledStateForAccount": [Function],
|
||||
"_resetNotebookWorkspace": [Function],
|
||||
"addCollectionPane": AddCollectionPane {
|
||||
"_databaseOffers": HashMap {
|
||||
"container": Object {},
|
||||
},
|
||||
"_isSynapseLinkEnabled": [Function],
|
||||
"autoPilotThroughput": [Function],
|
||||
"autoPilotTiersList": [Function],
|
||||
@ -1397,9 +1391,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"visible": [Function],
|
||||
},
|
||||
AddCollectionPane {
|
||||
"_databaseOffers": HashMap {
|
||||
"container": Object {},
|
||||
},
|
||||
"_isSynapseLinkEnabled": [Function],
|
||||
"autoPilotThroughput": [Function],
|
||||
"autoPilotTiersList": [Function],
|
||||
@ -1899,9 +1890,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"_refreshSparkEnabledStateForAccount": [Function],
|
||||
"_resetNotebookWorkspace": [Function],
|
||||
"addCollectionPane": AddCollectionPane {
|
||||
"_databaseOffers": HashMap {
|
||||
"container": Object {},
|
||||
},
|
||||
"_isSynapseLinkEnabled": [Function],
|
||||
"autoPilotThroughput": [Function],
|
||||
"autoPilotTiersList": [Function],
|
||||
@ -2723,9 +2711,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"visible": [Function],
|
||||
},
|
||||
AddCollectionPane {
|
||||
"_databaseOffers": HashMap {
|
||||
"container": Object {},
|
||||
},
|
||||
"_isSynapseLinkEnabled": [Function],
|
||||
"autoPilotThroughput": [Function],
|
||||
"autoPilotTiersList": [Function],
|
||||
@ -3225,9 +3210,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"_refreshSparkEnabledStateForAccount": [Function],
|
||||
"_resetNotebookWorkspace": [Function],
|
||||
"addCollectionPane": AddCollectionPane {
|
||||
"_databaseOffers": HashMap {
|
||||
"container": Object {},
|
||||
},
|
||||
"_isSynapseLinkEnabled": [Function],
|
||||
"autoPilotThroughput": [Function],
|
||||
"autoPilotTiersList": [Function],
|
||||
@ -4036,9 +4018,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"visible": [Function],
|
||||
},
|
||||
AddCollectionPane {
|
||||
"_databaseOffers": HashMap {
|
||||
"container": Object {},
|
||||
},
|
||||
"_isSynapseLinkEnabled": [Function],
|
||||
"autoPilotThroughput": [Function],
|
||||
"autoPilotTiersList": [Function],
|
||||
@ -4538,9 +4517,6 @@ exports[`SettingsComponent renders 1`] = `
|
||||
"_refreshSparkEnabledStateForAccount": [Function],
|
||||
"_resetNotebookWorkspace": [Function],
|
||||
"addCollectionPane": AddCollectionPane {
|
||||
"_databaseOffers": HashMap {
|
||||
"container": Object {},
|
||||
},
|
||||
"_isSynapseLinkEnabled": [Function],
|
||||
"autoPilotThroughput": [Function],
|
||||
"autoPilotTiersList": [Function],
|
||||
|
@ -101,12 +101,10 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
||||
public showUpsellMessage: ko.PureComputed<boolean>;
|
||||
public shouldCreateMongoWildcardIndex: ko.Observable<boolean>;
|
||||
|
||||
private _databaseOffers: HashMap<DataModels.Offer>;
|
||||
private _isSynapseLinkEnabled: ko.Computed<boolean>;
|
||||
|
||||
constructor(options: AddCollectionPaneOptions) {
|
||||
super(options);
|
||||
this._databaseOffers = new HashMap<DataModels.Offer>();
|
||||
this.hasAutoPilotV2FeatureFlag = ko.pureComputed(() => this.container.hasAutoPilotV2FeatureFlag());
|
||||
this.ruToolTipText = ko.pureComputed(() => PricingUtils.getRuToolTipText(this.hasAutoPilotV2FeatureFlag()));
|
||||
this.canConfigureThroughput = ko.pureComputed(() => !this.container.isServerlessEnabled());
|
||||
@ -481,7 +479,10 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
||||
}
|
||||
|
||||
if (!this.databaseCreateNew()) {
|
||||
this.databaseHasSharedOffer(this._databaseOffers.has(selectedDatabaseId));
|
||||
const selectedDatabase: ViewModels.Database = this.container
|
||||
.databases()
|
||||
.find((database: ViewModels.Database) => database.id() === selectedDatabaseId);
|
||||
this.databaseHasSharedOffer(!!selectedDatabase?.offer());
|
||||
}
|
||||
});
|
||||
|
||||
@ -749,15 +750,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
||||
}
|
||||
|
||||
private _onDatabasesChange(newDatabaseIds: ViewModels.Database[]) {
|
||||
const cachedDatabaseIdsList = _.map(newDatabaseIds, (database: ViewModels.Database) => {
|
||||
if (database && database.offer && database.offer()) {
|
||||
this._databaseOffers.set(database.id(), database.offer());
|
||||
}
|
||||
|
||||
return database.id();
|
||||
});
|
||||
|
||||
this.databaseIds(cachedDatabaseIdsList);
|
||||
this.databaseIds(newDatabaseIds?.map((database: ViewModels.Database) => database.id()));
|
||||
}
|
||||
|
||||
private _computeOfferThroughput(): number {
|
||||
|
Loading…
Reference in New Issue
Block a user