blob: 4689ca77352c9c36b8d8a3d9b35ac8fa464dea30 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
import useSWR from "swr";
import axios from "axios";
const fetcher = (url) => axios.get(url).then((res) => res.data);
const path =
"https://api.us-east.tinybird.co/v0/pipes/turborepo_time_saved_ticker.json?token=p.eyJ1IjogIjAzYzA0Y2MyLTM1YTAtNDhhNC05ZTZjLThhMWE0NGNhNjhkZiIsICJpZCI6ICJmOWIzMTU5Yi0wOTVjLTQyM2UtOWIwNS04ZDZlNzIyNjEwNzIifQ.A3TOPdm3Lhmn-1x5m6jNvulCQbbgUeQfAIO3IaaAt5k";
const REFRESH_INTERVAL_IN_MS = 3500;
interface QueryResponse {
meta: { name: string; type: string }[];
data: {
last_update_time: string;
remote_cache_minutes_saved: number;
local_cache_minutes_saved: number;
}[];
rows: number;
statistics: {
elapsed: number;
rows_read: number;
bytes_read: number;
};
}
export default function useTurborepoMinutesSaved():
| {
last_update_time: string;
remote_cache_minutes_saved: number;
local_cache_minutes_saved: number;
}
| undefined {
const swr = useSWR<QueryResponse, unknown>(path, fetcher, {
refreshInterval: REFRESH_INTERVAL_IN_MS,
});
return swr.data?.data[0];
}
|