feat: single shared Spaces key, deactivate/reactivate customer, status badge for inactive
Some checks failed
Build & Release / build (push) Has been cancelled

This commit is contained in:
Ryan Moon
2026-04-03 20:21:51 -05:00
parent 78503f993d
commit fe62514515
4 changed files with 74 additions and 36 deletions

View File

@@ -1,11 +1,10 @@
import postgres from "postgres";
import { db } from "../db/manager";
import { config } from "../lib/config";
import { getSecret } from "../lib/k8s";
import { getSpacesUsage } from "./spaces";
async function collectSizes() {
const customers = await db`SELECT slug, spaces_key FROM customers WHERE status = 'provisioned'`;
const customers = await db`SELECT slug FROM customers WHERE status = 'provisioned'`;
if (customers.length === 0) return;
for (const customer of customers) {
@@ -26,21 +25,17 @@ async function collectSizes() {
// Spaces size
let spacesSizeBytes: number | null = null;
let spacesObjectCount: number | null = null;
if (customer.spaces_key) {
try {
const namespace = `customer-${slug}`;
const secrets = await getSecret(namespace, "lunarfront-secrets");
const result = await getSpacesUsage(
customer.spaces_key,
secrets["spaces-secret"],
config.spacesBucket,
config.spacesRegion,
`${slug}/`,
);
spacesSizeBytes = result.sizeBytes;
spacesObjectCount = result.objectCount;
} catch {}
}
try {
const result = await getSpacesUsage(
config.spacesKey,
config.spacesSecret,
config.spacesBucket,
config.spacesRegion,
`${slug}/`,
);
spacesSizeBytes = result.sizeBytes;
spacesObjectCount = result.objectCount;
} catch {}
// Upsert today's snapshot (one row per day per customer)
await db`