mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-01-23 17:30:23 +00:00
24 lines
897 B
TypeScript
24 lines
897 B
TypeScript
import { any } from "underscore";
|
|
import { CollectionCreationDefaults } from "../Contracts/ViewModels";
|
|
import Explorer from "../Explorer/Explorer";
|
|
|
|
export const getMaxThroughput = (defaults: CollectionCreationDefaults, container: Explorer): number => {
|
|
const throughput = defaults.throughput.unlimited;
|
|
if (typeof throughput === "number") {
|
|
return throughput;
|
|
} else {
|
|
return _exceedsThreshold(throughput.collectionThreshold, container)
|
|
? throughput.greatThanThreshold
|
|
: throughput.lessThanOrEqualToThreshold;
|
|
}
|
|
};
|
|
|
|
const _exceedsThreshold = (unlimitedThreshold: number, container: Explorer): boolean => {
|
|
const databases = (container && container.databases && container.databases()) || [];
|
|
return any(
|
|
databases,
|
|
(database) =>
|
|
database && database.collections && database.collections() && database.collections().length > unlimitedThreshold
|
|
);
|
|
};
|