Skip to content

Commit

Permalink
refactor: tinybird structure (#1070)
Browse files Browse the repository at this point in the history
* refactor: tb

* feat: hover copy to clipboard

* wip: tcp

* chore: clean ups

* chore: format

* chore: format

* wip:

* ci: apply automated fixes

* fix: api

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
mxkaske and autofix-ci[bot] authored Oct 30, 2024
1 parent 0b91e08 commit e475b2a
Show file tree
Hide file tree
Showing 120 changed files with 2,386 additions and 1,982 deletions.
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

0 comments on commit e475b2a

Please sign in to comment.