(orgId: string, subscriptionId: string, usageCacheManager: UsageCacheManager)
| 126 | } |
| 127 | |
| 128 | export const checkPredictions = async (orgId: string, subscriptionId: string, usageCacheManager: UsageCacheManager) => { |
| 129 | if (!usageCacheManager || !subscriptionId) return |
| 130 | |
| 131 | const currentPredictions: number = (await usageCacheManager.get(`predictions:${orgId}`)) || 0 |
| 132 | |
| 133 | const quotas = await usageCacheManager.getQuotas(subscriptionId) |
| 134 | const predictionsLimit = quotas[LICENSE_QUOTAS.PREDICTIONS_LIMIT] |
| 135 | if (predictionsLimit === -1) return |
| 136 | |
| 137 | if (currentPredictions >= predictionsLimit) { |
| 138 | throw new InternalFlowiseError(StatusCodes.PAYMENT_REQUIRED, 'Predictions limit exceeded') |
| 139 | } |
| 140 | |
| 141 | return { |
| 142 | usage: currentPredictions, |
| 143 | limit: predictionsLimit |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | // Storage does not renew per month nor do we store the total size in database, so we just store the total size in cache |
| 148 | export const updateStorageUsage = (orgId: string, _: string = '', totalSize: number, usageCacheManager?: UsageCacheManager) => { |
no test coverage detected