Skip to content

Commit

Permalink
fix: charts (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
chronark authored Jul 8, 2023
1 parent 304c4ee commit 1d717c7
Show file tree
Hide file tree
Showing 23 changed files with 55 additions and 163 deletions.
2 changes: 1 addition & 1 deletion apps/api/pkg/env/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"testing"
"time"

"github.com/unkeyed/unkey/apps/api/pkg/env"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"github.com/unkeyed/unkey/apps/api/pkg/env"
)

func TestString_WhenSet(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/pkg/server/api_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"net/http"

"github.com/unkeyed/unkey/apps/api/pkg/database"
"github.com/gofiber/fiber/v2"
"github.com/unkeyed/unkey/apps/api/pkg/database"
)

type GetApiRequest struct {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/pkg/server/api_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (
"os"
"testing"

"github.com/stretchr/testify/require"
"github.com/unkeyed/unkey/apps/api/pkg/cache"
"github.com/unkeyed/unkey/apps/api/pkg/database"
"github.com/unkeyed/unkey/apps/api/pkg/entities"
"github.com/unkeyed/unkey/apps/api/pkg/logging"
"github.com/unkeyed/unkey/apps/api/pkg/testutil"
"github.com/unkeyed/unkey/apps/api/pkg/tracing"
"github.com/unkeyed/unkey/apps/api/pkg/uid"
"github.com/stretchr/testify/require"
)

func TestGetApi_Exists(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/pkg/server/key_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package server
import (
"errors"
"fmt"
"github.com/gofiber/fiber/v2"
"github.com/unkeyed/unkey/apps/api/pkg/database"
"github.com/unkeyed/unkey/apps/api/pkg/entities"
"github.com/unkeyed/unkey/apps/api/pkg/hash"
"github.com/unkeyed/unkey/apps/api/pkg/kafka"
"github.com/unkeyed/unkey/apps/api/pkg/keys"
"github.com/unkeyed/unkey/apps/api/pkg/uid"
"github.com/gofiber/fiber/v2"
"go.uber.org/zap"
"net/http"
"strings"
Expand Down
2 changes: 1 addition & 1 deletion apps/api/pkg/server/key_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"
"github.com/unkeyed/unkey/apps/api/pkg/cache"
"github.com/unkeyed/unkey/apps/api/pkg/database"
"github.com/unkeyed/unkey/apps/api/pkg/entities"
"github.com/unkeyed/unkey/apps/api/pkg/logging"
"github.com/unkeyed/unkey/apps/api/pkg/testutil"
"github.com/unkeyed/unkey/apps/api/pkg/tracing"
"github.com/stretchr/testify/require"
)

func TestCreateKey_Simple(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/pkg/server/key_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"github.com/unkeyed/unkey/apps/api/pkg/testutil"
"github.com/unkeyed/unkey/apps/api/pkg/tracing"

"github.com/unkeyed/unkey/apps/api/pkg/uid"
"github.com/stretchr/testify/require"
"github.com/unkeyed/unkey/apps/api/pkg/uid"
)

func TestDeleteKey(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/pkg/server/key_verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package server

import (
"errors"
"github.com/gofiber/fiber/v2"
"github.com/unkeyed/unkey/apps/api/pkg/database"
"github.com/unkeyed/unkey/apps/api/pkg/ratelimit"
"github.com/unkeyed/unkey/apps/api/pkg/tinybird"
"github.com/gofiber/fiber/v2"
"go.uber.org/zap"
"net/http"
"time"
Expand Down
2 changes: 1 addition & 1 deletion apps/api/pkg/server/key_verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import (
"github.com/unkeyed/unkey/apps/api/pkg/ratelimit"
"github.com/unkeyed/unkey/apps/api/pkg/tracing"

"github.com/stretchr/testify/require"
"github.com/unkeyed/unkey/apps/api/pkg/hash"
"github.com/unkeyed/unkey/apps/api/pkg/logging"
"github.com/unkeyed/unkey/apps/api/pkg/testutil"
"github.com/unkeyed/unkey/apps/api/pkg/uid"
"github.com/stretchr/testify/require"
)

func TestVerifyKey_Simple(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/pkg/server/keys_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package server
import (
"errors"
"fmt"
"github.com/unkeyed/unkey/apps/api/pkg/database"
"github.com/gofiber/fiber/v2"
"github.com/unkeyed/unkey/apps/api/pkg/database"
"net/http"
)

Expand Down
2 changes: 1 addition & 1 deletion apps/api/pkg/server/keys_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"
"github.com/unkeyed/unkey/apps/api/pkg/cache"
"github.com/unkeyed/unkey/apps/api/pkg/database"
"github.com/unkeyed/unkey/apps/api/pkg/entities"
Expand All @@ -18,7 +19,6 @@ import (
"github.com/unkeyed/unkey/apps/api/pkg/testutil"
"github.com/unkeyed/unkey/apps/api/pkg/tracing"
"github.com/unkeyed/unkey/apps/api/pkg/uid"
"github.com/stretchr/testify/require"
)

func TestListKeys_Simple(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/pkg/server/root_key_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"strings"
"time"

"github.com/gofiber/fiber/v2"
"github.com/unkeyed/unkey/apps/api/pkg/entities"
"github.com/unkeyed/unkey/apps/api/pkg/hash"
"github.com/unkeyed/unkey/apps/api/pkg/kafka"
"github.com/unkeyed/unkey/apps/api/pkg/keys"
"github.com/unkeyed/unkey/apps/api/pkg/uid"
"github.com/gofiber/fiber/v2"
)

type CreateRootKeyRequest struct {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/pkg/server/root_key_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"
"github.com/unkeyed/unkey/apps/api/pkg/cache"
"github.com/unkeyed/unkey/apps/api/pkg/entities"
"github.com/unkeyed/unkey/apps/api/pkg/logging"
"github.com/unkeyed/unkey/apps/api/pkg/testutil"
"github.com/unkeyed/unkey/apps/api/pkg/tracing"
"github.com/stretchr/testify/require"
)

func TestRootCreateKey_Simple(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (

"github.com/gofiber/fiber/v2"

"github.com/go-playground/validator/v10"
"github.com/unkeyed/unkey/apps/api/pkg/cache"
"github.com/unkeyed/unkey/apps/api/pkg/database"
"github.com/unkeyed/unkey/apps/api/pkg/entities"
"github.com/unkeyed/unkey/apps/api/pkg/kafka"
"github.com/unkeyed/unkey/apps/api/pkg/logging"
"github.com/unkeyed/unkey/apps/api/pkg/ratelimit"
"github.com/unkeyed/unkey/apps/api/pkg/tinybird"
"github.com/go-playground/validator/v10"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)
Expand Down
2 changes: 1 addition & 1 deletion apps/api/pkg/server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package server
import (
"strings"

"github.com/unkeyed/unkey/apps/api/pkg/hash"
"github.com/gofiber/fiber/v2"
"github.com/unkeyed/unkey/apps/api/pkg/hash"
)

// Return the hash of the key used for authentication
Expand Down
4 changes: 2 additions & 2 deletions apps/api/pkg/testutil/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
"testing"
"time"

"github.com/google/uuid"
"github.com/stretchr/testify/require"
"github.com/unkeyed/unkey/apps/api/pkg/database"
"github.com/unkeyed/unkey/apps/api/pkg/entities"
"github.com/unkeyed/unkey/apps/api/pkg/hash"
"github.com/unkeyed/unkey/apps/api/pkg/logging"
"github.com/unkeyed/unkey/apps/api/pkg/uid"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
)

type resources struct {
Expand Down
91 changes: 0 additions & 91 deletions apps/web/app/(authenticated)/(app)/app/[apiId]/ApiPage.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,13 @@ export default async function ApiPage(props: { params: { keyId: string } }) {
keyId: key.id,
});

const now = new Date();
const year = now.getUTCFullYear();
const month = now.getUTCMonth();
const start = new Date(year, month, 0, 0, 0, 0, 0);
const end = new Date(start.getTime());
end.setUTCMonth(end.getUTCMonth() + 1);
const end = new Date().setUTCHours(0, 0, 0, 0);
const start = end - 30 * 24 * 60 * 60 * 1000;

const usageOverTime = fillRange(
usage.data.map(({ time, usage }) => ({ value: usage, time })),
start.getTime(),
end.getTime(),
"1d",
start,
end,
).map(({ value, time }) => ({
x: new Date(time).toUTCString(),
y: value,
Expand Down
21 changes: 8 additions & 13 deletions apps/web/app/(authenticated)/(app)/app/[apiId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { db, eq, schema } from "@unkey/db";
import { getActiveCount, getUsage } from "@/lib/tinybird";
import { sql } from "drizzle-orm";
import { redirect } from "next/navigation";
import { formatNumber } from "@/lib/fmt";

export const revalidate = 0;

Expand Down Expand Up @@ -38,21 +39,15 @@ export default async function ApiPage(props: { params: { apiId: string } }) {
workspaceId: api.workspaceId,
apiId: api.id,
});
const now = new Date();
const year = now.getUTCFullYear();
const month = now.getUTCMonth();
const start = new Date(year, month, 0, 0, 0, 0, 0);
const end = new Date(start.getTime());
end.setUTCMonth(end.getUTCMonth() + 1);

const end = new Date().setUTCHours(0, 0, 0, 0);
const start = end - 30 * 24 * 60 * 60 * 1000;
const keys = await keysP;
const active = await activeP;

const usageOverTime = fillRange(
usage.data.map(({ time, usage }) => ({ value: usage, time })),
start.getTime(),
end.getTime(),
"1d",
start,
end,
).map(({ value, time }) => ({
x: new Date(time).toUTCString(),
y: value,
Expand All @@ -62,19 +57,19 @@ export default async function ApiPage(props: { params: { apiId: string } }) {
<div className="grid grid-cols-3 gap-4">
<Card className="col-span-1">
<CardHeader>
<CardTitle>{keys}</CardTitle>
<CardTitle>{formatNumber(keys)}</CardTitle>
<CardDescription>Total Keys</CardDescription>
</CardHeader>
</Card>
<Card className="col-span-1">
<CardHeader>
<CardTitle>{active.data.at(0)?.active ?? 0}</CardTitle>
<CardTitle>{formatNumber(active.data.at(0)?.active ?? 0)}</CardTitle>
<CardDescription>Active Keys (30 days)</CardDescription>
</CardHeader>
</Card>
<Card className="col-span-1">
<CardHeader>
<CardTitle>{usage.data.reduce((sum, day) => sum + day.usage, 0)}</CardTitle>
<CardTitle>{formatNumber(usage.data.reduce((sum, day) => sum + day.usage, 0))}</CardTitle>
<CardDescription>Verifications (30 days)</CardDescription>
</CardHeader>
</Card>
Expand Down
1 change: 0 additions & 1 deletion apps/web/app/(authenticated)/(app)/app/settings/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export default async function SettingsPage() {
usage.data.map(({ time, usage }) => ({ value: usage, time })),
start.getTime(),
end.getTime(),
"1d",
).map(({ value, time }) => ({
x: new Date(time).toUTCString(),
y: value,
Expand Down
Loading

1 comment on commit 1d717c7

@vercel
Copy link

@vercel vercel bot commented on 1d717c7 Jul 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

unkey – ./

unkey.vercel.app
unkey-unkey.vercel.app
unkey-git-main-unkey.vercel.app
unkey.dev
www.unkey.dev

Please sign in to comment.