1
0
Fork 0
mirror of synced 2024-06-28 02:50:50 +12:00

minor renaming

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

View file

@ -34,13 +34,12 @@ describe("/rows", () => {
.expect(status) .expect(status)
const getRowUsage = async () => { const getRowUsage = async () => {
return config.doInContext(null, () => const { total } = await config.doInContext(null, () => quotas.getCurrentUsageValues(QuotaUsageType.STATIC, StaticQuotaName.ROWS))
quotas.getCurrentUsageValue(QuotaUsageType.STATIC, StaticQuotaName.ROWS) return total
)
} }
const getQueryUsage = async () => { 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 return total
} }

View file

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