Skip to content

Commit 63f1284

Browse files
authored
remove driver usage endpoint (#3017)
1 parent 5e8e9a8 commit 63f1284

1 file changed

Lines changed: 0 additions & 51 deletions

File tree

src/backend/controllers/drivers/DriverController.ts

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,6 @@ export class DriverController extends PuterController {
175175
{ subdomain: 'api', requireAuth: true },
176176
this.#handleXd,
177177
);
178-
router.get(
179-
'/usage',
180-
{ subdomain: 'api', requireAuth: true },
181-
this.#handleUsage,
182-
);
183178
}
184179

185180
// ── Handlers ────────────────────────────────────────────────────
@@ -315,52 +310,6 @@ export class DriverController extends PuterController {
315310
res.send(XD_HTML);
316311
};
317312

318-
/** GET /drivers/usage — monthly driver usage for the authenticated actor. */
319-
#handleUsage = async (req: Request, res: Response): Promise<void> => {
320-
const actor = req.actor;
321-
if (!actor?.user?.id)
322-
throw new HttpError(401, 'Authentication required');
323-
324-
const userId = actor.user.id;
325-
const db = this.clients.db;
326-
327-
// Per-user usage: aggregate today's counts from monthly_usage_counts
328-
const userRows = await db.read(
329-
`SELECT \`year\`, \`month\`, \`service\`, SUM(\`count\`) AS count, MAX(\`max\`) AS max
330-
FROM \`monthly_usage_counts\`
331-
WHERE \`user_id\` = ? AND \`app_id\` IS NULL
332-
GROUP BY \`year\`, \`month\`, \`service\`
333-
ORDER BY \`year\` DESC, \`month\` DESC
334-
LIMIT 100`,
335-
[userId],
336-
);
337-
338-
// Per-app usage: aggregate by app
339-
const appRows = await db.read(
340-
`SELECT a.\`uid\` AS app_uid, a.\`name\` AS app_name,
341-
m.\`year\`, m.\`month\`, m.\`service\`, SUM(m.\`count\`) AS count, MAX(m.\`max\`) AS max
342-
FROM \`monthly_usage_counts\` m
343-
LEFT JOIN \`apps\` a ON m.\`app_id\` = a.\`id\`
344-
WHERE m.\`user_id\` = ? AND m.\`app_id\` IS NOT NULL
345-
GROUP BY a.\`uid\`, a.\`name\`, m.\`year\`, m.\`month\`, m.\`service\`
346-
ORDER BY m.\`year\` DESC, m.\`month\` DESC
347-
LIMIT 500`,
348-
[userId],
349-
);
350-
351-
// Group app rows by app name
352-
const apps: Record<string, Array<Record<string, unknown>>> = {};
353-
for (const row of appRows) {
354-
const name = String(
355-
(row as Record<string, unknown>).app_name ?? 'unknown',
356-
);
357-
if (!apps[name]) apps[name] = [];
358-
apps[name].push(row as Record<string, unknown>);
359-
}
360-
361-
res.json({ user: userRows, apps });
362-
};
363-
364313
// ── Internals ───────────────────────────────────────────────────
365314

366315
#buildIfaceMap(): void {

0 commit comments

Comments
 (0)