Rename tiers and get working

This commit is contained in:
Owen
2026-02-08 17:55:26 -08:00
parent c41e8be3e8
commit 81ef2db7f8
36 changed files with 326 additions and 175 deletions

View File

@@ -354,7 +354,7 @@ export async function createOrgDomain(
});
if (numOrgDomains) {
await usageService.updateDaily(
await usageService.updateCount(
orgId,
FeatureId.DOMAINS,
numOrgDomains.length

View File

@@ -86,7 +86,7 @@ export async function deleteAccountDomain(
});
if (numOrgDomains) {
await usageService.updateDaily(
await usageService.updateCount(
orgId,
FeatureId.DOMAINS,
numOrgDomains.length

View File

@@ -587,7 +587,7 @@ export async function validateOidcCallback(
});
for (const orgCount of orgUserCounts) {
await usageService.updateDaily(
await usageService.updateCount(
orgCount.orgId,
FeatureId.USERS,
orgCount.userCount

View File

@@ -107,7 +107,7 @@ export const handleNewtRegisterMessage: MessageHandler = async (context) => {
FeatureId.EGRESS_DATA_MB
);
// Do we need to check the users and domains daily limits here?
// Do we need to check the users and domains count limits here?
// const rejectUsers = await usageService.checkLimitSet(oldSite.orgId, false, FeatureId.USERS);
// const rejectDomains = await usageService.checkLimitSet(oldSite.orgId, false, FeatureId.DOMAINS);

View File

@@ -271,7 +271,7 @@ export async function createOrg(
// make sure we have the stripe customer
const customerId = await createCustomer(orgId, req.user?.email);
if (customerId) {
await usageService.updateDaily(
await usageService.updateCount(
orgId,
FeatureId.USERS,
1,

View File

@@ -440,7 +440,7 @@ export async function createSite(
});
if (numSites) {
await usageService.updateDaily(
await usageService.updateCount(
orgId,
FeatureId.SITES,
numSites.length

View File

@@ -110,7 +110,7 @@ export async function deleteSite(
});
if (numSites) {
await usageService.updateDaily(
await usageService.updateCount(
site.orgId,
FeatureId.SITES,
numSites.length

View File

@@ -155,17 +155,19 @@ export async function acceptInvite(
.delete(userInvites)
.where(eq(userInvites.inviteId, inviteId));
await calculateUserClientsForOrgs(existingUser[0].userId, trx);
// Get the total number of users in the org now
totalUsers = await db
totalUsers = await trx
.select()
.from(userOrgs)
.where(eq(userOrgs.orgId, existingInvite.orgId));
await calculateUserClientsForOrgs(existingUser[0].userId, trx);
logger.debug(`User ${existingUser[0].userId} accepted invite to org ${existingInvite.orgId}. Total users in org: ${totalUsers.length}`);
});
if (totalUsers) {
await usageService.updateDaily(
await usageService.updateCount(
existingInvite.orgId,
FeatureId.USERS,
totalUsers.length

View File

@@ -254,7 +254,7 @@ export async function createOrgUser(
});
if (orgUsers) {
await usageService.updateDaily(
await usageService.updateCount(
orgId,
FeatureId.USERS,
orgUsers.length

View File

@@ -140,7 +140,7 @@ export async function removeUserOrg(
});
if (userCount) {
await usageService.updateDaily(
await usageService.updateCount(
orgId,
FeatureId.USERS,
userCount.length