Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ratelimits ui filters and logs ordering #2811

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";
import { ArrayInput } from "@/components/array-input";
import { cn } from "@/lib/utils";
import { Button } from "@unkey/ui";
import { Button, buttonVariants } from "@unkey/ui";
import {
CalendarIcon,
CalendarRange,
Expand Down Expand Up @@ -193,20 +193,22 @@ export const Filters: React.FC = () => {
}
timeInputLabel="Select Time"
calendarProps={{
disabled: { before: new Date() },
disabled: { after: new Date() },
showOutsideDays: true,
}}
timeInputProps={{
className: "w-[100px]",
}}
>
<Button className="text-xs font-medium w-full justify-start gap-0">
<span className="mr-1 text-xs font-medium">From:</span>
<div
className={cn("text-xs font-medium w-full items-center gap-0", buttonVariants())}
>
<span className="mr-1 font-medium">From:</span>

{after ? format(after, "PPp") : format(new Date(), "PPp")}

<CalendarIcon className="mr-2 h-4 w-4 ml-auto" />
</Button>
</div>
</DateTimePicker>
<div className="flex items-center w-full gap-2">
<DateTimePicker
Expand All @@ -225,13 +227,15 @@ export const Filters: React.FC = () => {
className: "w-[130px]",
}}
>
<Button className="text-xs font-medium w-full justify-start gap-0">
<span className="mr-1 text-xs font-medium">Until:</span>
<div
className={cn("text-xs font-medium w-full items-center gap-0", buttonVariants())}
>
<span className="mr-1 font-medium">Until:</span>

{before ? format(before, "PPp") : format(new Date(), "PPp")}

<CalendarIcon className="mr-2 h-4 w-4 ml-auto" />
</Button>
</div>
</DateTimePicker>
</div>

Expand Down
3 changes: 3 additions & 0 deletions internal/clickhouse/src/ratelimits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ const getRatelimitLogsParameters = z.object({
.optional()
.default(() => Date.now()),
limit: z.number().optional().default(100),
passed: z.boolean().optional(),
});

export function getRatelimitLogs(ch: Querier) {
Expand All @@ -180,6 +181,8 @@ export function getRatelimitLogs(ch: Querier) {
${args.identifier ? "AND multiSearchAny(identifier, {identifier: Array(String)}) > 0" : ""}
AND time >= {start: Int64}
AND time <= {end: Int64}
${typeof args.passed !== "undefined" ? "passed = {passed:Boolean}" : ""}
ORDER BY time DESC
LIMIT {limit: Int64}
;`,
params: getRatelimitLogsParameters,
Expand Down
11 changes: 2 additions & 9 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,12 @@
"publishConfig": {
"access": "public"
},
"keywords": [
"unkey",
"client",
"api"
],
"keywords": ["unkey", "client", "api"],
"bugs": {
"url": "https://github.com/unkeyed/unkey/issues"
},
"homepage": "https://github.com/unkeyed/unkey#readme",
"files": [
"./dist/**",
"README.md"
],
"files": ["./dist/**", "README.md"],
"author": "Andreas Thomas <andreas@chronark.com>",
"scripts": {
"generate": "openapi-typescript https://api.unkey.dev/openapi.json -o ./src/openapi.d.ts",
Expand Down
11 changes: 2 additions & 9 deletions packages/hono/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@
"publishConfig": {
"access": "public"
},
"keywords": [
"unkey",
"client",
"api",
"hono"
],
"keywords": ["unkey", "client", "api", "hono"],
"bugs": {
"url": "https://github.com/unkeyed/unkey/issues"
},
"homepage": "https://github.com/unkeyed/unkey#readme",
"files": [
"./dist/**"
],
"files": ["./dist/**"],
"author": "Andreas Thomas <andreas@chronark.com>",
"scripts": {
"build": "tsup",
Expand Down
11 changes: 2 additions & 9 deletions packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@
"publishConfig": {
"access": "public"
},
"keywords": [
"unkey",
"client",
"api"
],
"keywords": ["unkey", "client", "api"],
"bugs": {
"url": "https://github.com/unkeyed/unkey/issues"
},
"homepage": "https://github.com/unkeyed/unkey#readme",
"files": [
"./dist/**",
"README.md"
],
"files": ["./dist/**", "README.md"],
"author": "Andreas Thomas <andreas@chronark.com>",
"scripts": {
"build": "tsup"
Expand Down
12 changes: 2 additions & 10 deletions packages/ratelimit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,12 @@
"publishConfig": {
"access": "public"
},
"keywords": [
"unkey",
"ratelimit",
"global",
"serverless"
],
"keywords": ["unkey", "ratelimit", "global", "serverless"],
"bugs": {
"url": "https://github.com/unkeyed/unkey/issues"
},
"homepage": "https://github.com/unkeyed/unkey#readme",
"files": [
"./dist/**",
"README.md"
],
"files": ["./dist/**", "README.md"],
"author": "Andreas Thomas <andreas@unkey.dev>",
"scripts": {
"build": "tsup"
Expand Down
Loading