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

refactor: tinybird structure #1070

Merged
merged 10 commits into from
Oct 30, 2024
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
8 changes: 4 additions & 4 deletions apps/server/src/v1/monitors/results/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { openApiErrorResponses } from "../../../libs/errors/openapi-error-respon
import type { monitorsApi } from "../index";
import { ParamsSchema, ResultRun } from "../schema";

const tb = new OSTinybird({ token: env.TINY_BIRD_API_KEY });
const tb = new OSTinybird(env.TINY_BIRD_API_KEY);

const getMonitorStats = createRoute({
method: "get",
Expand Down Expand Up @@ -69,15 +69,15 @@ export function registerGetMonitorResult(api: typeof monitorsApi) {
throw new HTTPException(404, { message: "Not Found" });
}
// Fetch result from tb pipe
const data = await tb.getResultForOnDemandCheckHttp()({
const data = await tb.getResultForOnDemandCheckHttp({
monitorId: _monitor.id,
timestamp: _monitorRun.runnedAt?.getTime(),
url: _monitor.url,
});
// return array of results
if (!data) {
if (!data || data.data.length === 0) {
throw new HTTPException(404, { message: "Not Found" });
}
return c.json(data, 200);
return c.json(data.data, 200);
});
}
11 changes: 4 additions & 7 deletions apps/server/src/v1/monitors/summary/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { isoDate } from "../../utils";
import type { monitorsApi } from "../index";
import { ParamsSchema } from "../schema";

const tb = new OSTinybird({ token: env.TINY_BIRD_API_KEY });
const tb = new OSTinybird(env.TINY_BIRD_API_KEY);
const redis = Redis.fromEnv();

const dailyStatsSchema = z.object({
Expand Down Expand Up @@ -82,17 +82,14 @@ export function registerGetMonitorSummary(api: typeof monitorsApi) {
return c.json({ data: cache }, 200);
}

// FIXME: we should use the OSTinybird client
console.log("fetching from tinybird");
const res = await tb.endpointStatusPeriod("45d")({
monitorId: id,
});
const res = await tb.httpStatus45d({ monitorId: id });

if (res === undefined) {
if (!res || res.data.length === 0) {
throw new HTTPException(404, { message: "Not Found" });
}
await redis.set(`${id}-daily-stats`, res, { ex: 600 });

return c.json({ data: res }, 200);
return c.json({ data: res.data }, 200);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { mockTrackerData } from "../mock";
export function TrackerWithVisibilityToggle() {
const [visible, setVisible] = useState(true);
return (
<div className="flex flex-col gap-8 my-auto">
<div className="my-auto flex flex-col gap-8">
<div className="items-top flex space-x-2">
<Checkbox
id="visibility"
Expand All @@ -18,11 +18,11 @@ export function TrackerWithVisibilityToggle() {
<div className="grid gap-1.5 leading-none">
<label
htmlFor="visibility"
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
className="font-medium text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
>
Show values
</label>
<p className="text-sm text-muted-foreground">
<p className="text-muted-foreground text-sm">
Share the uptime and number of requests.
</p>
</div>
Expand Down
3 changes: 1 addition & 2 deletions apps/web/src/app/(content)/features/monitoring/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import { Chart } from "@/components/monitor-charts/chart";
import { RegionsPreset } from "@/components/monitor-dashboard/region-preset";
import { ResponseDetailTabs } from "@/components/ping-response-analysis/response-detail-tabs";
import { marketingProductPagesConfig } from "@/config/pages";
import { flyRegions } from "@openstatus/db/src/schema/constants";
import type { Region } from "@openstatus/tinybird";
import { type Region, flyRegions } from "@openstatus/db/src/schema/constants";
import { Button } from "@openstatus/ui/src/components/button";
import { Skeleton } from "@openstatus/ui/src/components/skeleton";
import { allUnrelateds } from "contentlayer/generated";
Expand Down
94 changes: 0 additions & 94 deletions apps/web/src/app/_components/event-table.tsx

This file was deleted.

200 changes: 0 additions & 200 deletions apps/web/src/app/_components/input-search.tsx

This file was deleted.

Loading
Loading