Explorar o código

tweak: usage endpoint

KernelDeimos hai 6 meses
pai
achega
fc0cb2dde4
Modificáronse 1 ficheiros con 11 adicións e 2 borrados
  1. 11 2
      src/backend/src/routers/drivers/usage.js

+ 11 - 2
src/backend/src/routers/drivers/usage.js

@@ -87,6 +87,9 @@ module.exports = eggspress('/drivers/usage', {
         if ( ! identifying_fields.service['driver.implementation'] ) {
             continue;
         }
+        if ( identifying_fields.service['driver.interface'] === 'puter-es' ) {
+            continue;
+        }
 
         const svc_driverUsage = req.services.get('driver-usage-policy');
         const policy = await svc_driverUsage.get_effective_policy({
@@ -94,7 +97,7 @@ module.exports = eggspress('/drivers/usage', {
             service_name: identifying_fields.service['driver.implementation'],
             trait_name: identifying_fields.service['driver.interface'],
         });
-
+        
         // console.log(`POLICY FOR ${identifying_fields.service['driver.implementation']} ${identifying_fields.service['driver.interface']}`, policy);
 
         const user_usage_key = hash_serializable_object(identifying_fields);
@@ -104,7 +107,13 @@ module.exports = eggspress('/drivers/usage', {
                 ...identifying_fields,
                 policy,
             };
-            usages.user[user_usage_key].monthly_limit = policy?.['monthy-limit'] ?? null;
+            usages.user[user_usage_key].monthly_limit =
+                policy?.['monthly-limit'] ??
+                policy?.['monthy-limit'] ??
+                null;
+            if ( ! policy ) {
+                usages.user[user_usage_key].monthly_limit = 0;
+            }
         }
 
         usages.user[user_usage_key].monthly_usage =