mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-01 22:10:23 +00:00
zen: fix usage graph
This commit is contained in:
parent
8bf97ef9e5
commit
0f1fdeceda
1 changed files with 3 additions and 3 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import { and, Database, eq, gte, inArray, isNull, lte, or, sql, sum } from "@opencode-ai/console-core/drizzle/index.js"
|
import { and, Database, eq, gte, inArray, isNull, lt, or, sql, sum } from "@opencode-ai/console-core/drizzle/index.js"
|
||||||
import { UsageTable } from "@opencode-ai/console-core/schema/billing.sql.js"
|
import { UsageTable } from "@opencode-ai/console-core/schema/billing.sql.js"
|
||||||
import { KeyTable } from "@opencode-ai/console-core/schema/key.sql.js"
|
import { KeyTable } from "@opencode-ai/console-core/schema/key.sql.js"
|
||||||
import { UserTable } from "@opencode-ai/console-core/schema/user.sql.js"
|
import { UserTable } from "@opencode-ai/console-core/schema/user.sql.js"
|
||||||
|
|
@ -27,7 +27,7 @@ async function getCosts(workspaceID: string, year: number, month: number) {
|
||||||
"use server"
|
"use server"
|
||||||
return withActor(async () => {
|
return withActor(async () => {
|
||||||
const startDate = new Date(year, month, 1)
|
const startDate = new Date(year, month, 1)
|
||||||
const endDate = new Date(year, month + 1, 0)
|
const endDate = new Date(year, month + 1, 1)
|
||||||
const usageData = await Database.use((tx) =>
|
const usageData = await Database.use((tx) =>
|
||||||
tx
|
tx
|
||||||
.select({
|
.select({
|
||||||
|
|
@ -42,7 +42,7 @@ async function getCosts(workspaceID: string, year: number, month: number) {
|
||||||
and(
|
and(
|
||||||
eq(UsageTable.workspaceID, workspaceID),
|
eq(UsageTable.workspaceID, workspaceID),
|
||||||
gte(UsageTable.timeCreated, startDate),
|
gte(UsageTable.timeCreated, startDate),
|
||||||
lte(UsageTable.timeCreated, endDate),
|
lt(UsageTable.timeCreated, endDate),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.groupBy(
|
.groupBy(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue