minor renaming

This commit is contained in:
Rory Powell 2022-09-28 11:57:58 +01:00
parent 79226777b1
commit b230f16369
2 changed files with 13 additions and 14 deletions

View File

@ -34,13 +34,12 @@ describe("/rows", () => {
.expect(status)
const getRowUsage = async () => {
return config.doInContext(null, () =>
quotas.getCurrentUsageValue(QuotaUsageType.STATIC, StaticQuotaName.ROWS)
)
const { total } = await config.doInContext(null, () => quotas.getCurrentUsageValues(QuotaUsageType.STATIC, StaticQuotaName.ROWS))
return total
}
const getQueryUsage = async () => {
const { total } = await config.doInContext(null, () => quotas.getAllCurrentUsageValue(QuotaUsageType.MONTHLY, MonthlyQuotaName.QUERIES))
const { total } = await config.doInContext(null, () => quotas.getCurrentUsageValues(QuotaUsageType.MONTHLY, MonthlyQuotaName.QUERIES))
return total
}

View File

@ -6,52 +6,52 @@ export enum BreakdownQuotaName {
AUTOMATIONS = "automations",
}
export const StoredByAppQuotaNames = [
export const APP_QUOTA_NAMES = [
StaticQuotaName.ROWS,
MonthlyQuotaName.QUERIES,
MonthlyQuotaName.AUTOMATIONS,
]
export const NamesToBreakdown = [
export const BREAKDOWN_QUOTA_NAMES = [
MonthlyQuotaName.QUERIES,
MonthlyQuotaName.AUTOMATIONS,
]
export interface Breakdown {
export interface UsageBreakdown {
parent: MonthlyQuotaName
values: {
[key: string]: number
}
}
export type Monthly = {
export type MonthlyUsage = {
[MonthlyQuotaName.QUERIES]: number
[MonthlyQuotaName.AUTOMATIONS]: number
[MonthlyQuotaName.DAY_PASSES]: number
breakdown?: {
[key in BreakdownQuotaName]?: Breakdown
[key in BreakdownQuotaName]?: UsageBreakdown
}
}
export interface UsageInternal {
export interface BaseQuotaUsage {
usageQuota: {
[key in StaticQuotaName]: number
}
monthly: {
[key: string]: Monthly
[key: string]: MonthlyUsage
}
}
export interface QuotaUsage extends UsageInternal {
export interface QuotaUsage extends BaseQuotaUsage {
_id: string
_rev?: string
quotaReset: string
apps?: {
[key: string]: UsageInternal
[key: string]: BaseQuotaUsage
}
}
export type QuotaValues = {
export type UsageValues = {
total: number
app?: number
breakdown?: number