MCPcopy
hub / github.com/FlowiseAI/Flowise / getCurrentUsage

Function getCurrentUsage

packages/server/src/utils/quotaUsage.ts:22–47  ·  view source on GitHub ↗
(orgId: string, subscriptionId: string, usageCacheManager: UsageCacheManager)

Source from the content-addressed store, hash-verified

20]
21
22export const getCurrentUsage = async (orgId: string, subscriptionId: string, usageCacheManager: UsageCacheManager) => {
23 try {
24 if (!usageCacheManager || !subscriptionId || !orgId) return
25
26 const currentStorageUsage = (await usageCacheManager.get(`storage:${orgId}`)) || 0
27 const currentPredictionsUsage = (await usageCacheManager.get(`predictions:${orgId}`)) || 0
28
29 const quotas = await usageCacheManager.getQuotas(subscriptionId)
30 const storageLimit = quotas[LICENSE_QUOTAS.STORAGE_LIMIT]
31 const predLimit = quotas[LICENSE_QUOTAS.PREDICTIONS_LIMIT]
32
33 return {
34 predictions: {
35 usage: currentPredictionsUsage,
36 limit: predLimit
37 },
38 storage: {
39 usage: currentStorageUsage,
40 limit: storageLimit
41 }
42 }
43 } catch (error) {
44 logger.error(`[getCurrentUsage] Error getting usage: ${error}`)
45 throw error
46 }
47}
48
49// For usage that doesn't renew per month, we just get the count from database and check
50export const checkUsageLimit = async (

Callers 1

getCurrentUsageMethod · 0.90

Calls 2

getQuotasMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected