import { getTenantId } from "@devlego/backend-core/tenancy"
import { utils } from "@devlego/backend-core"
import { quotas, QuotaUsageType, StaticQuotaName } from "@devlego/pro"

export const run = async () => {
  // get developer count
  const developerCount = await utils.getBuildersCount()

  // sync developer count
  const tenantId = getTenantId()
  console.log(
    `[Tenant: ${tenantId}] Syncing developer count: ${developerCount}`
  )
  await quotas.setUsage(
    developerCount,
    StaticQuotaName.DEVELOPERS,
    QuotaUsageType.STATIC
  )
}
