mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Add the timestamp of the last event to the Developers tab (#81)
This commit is contained in:
parent
fff8dc3474
commit
9fd31aaf6c
2 changed files with 28 additions and 2 deletions
|
|
@ -191,6 +191,7 @@ const developerUsageSchema = z.object({
|
|||
tasksCompleted: z.coerce.number(),
|
||||
tokens: z.coerce.number(),
|
||||
cost: z.coerce.number(),
|
||||
lastEventTimestamp: z.coerce.number(),
|
||||
});
|
||||
|
||||
export type DeveloperUsage = z.infer<typeof developerUsageSchema> & {
|
||||
|
|
@ -237,7 +238,8 @@ export const getDeveloperUsage = async ({
|
|||
SUM(CASE WHEN type = '${TelemetryEventName.TASK_CREATED}' THEN 1 ELSE 0 END) AS tasksStarted,
|
||||
SUM(CASE WHEN type = '${TelemetryEventName.TASK_COMPLETED}' THEN 1 ELSE 0 END) AS tasksCompleted,
|
||||
SUM(CASE WHEN type = '${TelemetryEventName.LLM_COMPLETION}' THEN COALESCE(inputTokens, 0) + COALESCE(outputTokens, 0) ELSE 0 END) AS tokens,
|
||||
SUM(CASE WHEN type = '${TelemetryEventName.LLM_COMPLETION}' THEN COALESCE(cost, 0) ELSE 0 END) AS cost
|
||||
SUM(CASE WHEN type = '${TelemetryEventName.LLM_COMPLETION}' THEN COALESCE(cost, 0) ELSE 0 END) AS cost,
|
||||
MAX(timestamp) AS lastEventTimestamp
|
||||
FROM events
|
||||
WHERE orgId = {orgId: String}
|
||||
AND timestamp >= toUnixTimestamp(now() - INTERVAL {timePeriod: Int32} DAY)
|
||||
|
|
|
|||
|
|
@ -2,9 +2,14 @@ import { useMemo } from 'react';
|
|||
import { useQuery } from '@tanstack/react-query';
|
||||
import type { ColumnDef } from '@tanstack/react-table';
|
||||
import { useAuth } from '@clerk/nextjs';
|
||||
import { formatDistance } from 'date-fns';
|
||||
|
||||
import { type DeveloperUsage, getDeveloperUsage } from '@/actions/analytics';
|
||||
import { formatCurrency, formatNumber } from '@/lib/formatters';
|
||||
import {
|
||||
formatCurrency,
|
||||
formatNumber,
|
||||
formatTimestamp,
|
||||
} from '@/lib/formatters';
|
||||
import { Button, Skeleton } from '@/components/ui';
|
||||
import { DataTable } from '@/components/layout';
|
||||
|
||||
|
|
@ -63,6 +68,25 @@ export const Developers = ({
|
|||
header: 'Cost (USD)',
|
||||
cell: ({ row }) => formatCurrency(row.original.cost),
|
||||
},
|
||||
{
|
||||
header: 'Last Event',
|
||||
cell: ({ row }) => {
|
||||
const timestamp = row.original.lastEventTimestamp;
|
||||
if (!timestamp) return 'No activity';
|
||||
|
||||
const date = new Date(timestamp * 1000);
|
||||
const relativeTime = formatDistance(date, new Date(), {
|
||||
addSuffix: true,
|
||||
});
|
||||
const absoluteTime = formatTimestamp(timestamp);
|
||||
|
||||
return (
|
||||
<span title={absoluteTime} className="cursor-help">
|
||||
{relativeTime}
|
||||
</span>
|
||||
);
|
||||
},
|
||||
},
|
||||
],
|
||||
[onFilter],
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue