Update member resources page and testing new org counts

This commit is contained in:
Owen
2026-02-17 20:01:15 -08:00
parent a2ed22bfcc
commit 6661a76aa8
7 changed files with 347 additions and 39 deletions

View File

@@ -130,18 +130,22 @@ export class UsageService {
featureId,
orgId,
meterId,
instantaneousValue: value,
latestValue: value,
instantaneousValue: value || 0,
latestValue: value || 0,
updatedAt: Math.floor(Date.now() / 1000)
})
.onConflictDoUpdate({
target: usage.usageId,
set: {
instantaneousValue: sql`${usage.instantaneousValue} + ${value}`
instantaneousValue: sql`COALESCE(${usage.instantaneousValue}, 0) + ${value}`
}
})
.returning();
logger.debug(
`Added usage for org ${orgId} feature ${featureId}: +${value}, new instantaneousValue: ${returnUsage.instantaneousValue}`
);
return returnUsage;
}