Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 39 40 41 42 43 44 45 46 47 48 49 50 51 | 1x 1x 1x 4x 4x 8x 8x 4x | import { useQuery } from "@tanstack/react-query";
import Sentry from "platform/sentry";
interface WeblateLanguage {
code: string;
name: string;
translated_percent: number;
}
const fetchWeblateStats = async (): Promise<WeblateLanguage[]> => {
try {
const response = await fetch(
"https://cdn.couchers.org/api/projects/couchers/languages/",
{
headers: {
Accept: "application/json",
},
},
);
Iif (!response.ok) {
Sentry.captureException(
new Error(
`Weblate API error: ${response.status} ${response.statusText}`,
),
);
throw new Error(
`Weblate API error: ${response.status} ${response.statusText}`,
);
}
const languages: WeblateLanguage[] = await response.json();
return languages || [];
} catch (error) {
console.error("Error fetching Weblate stats:", error);
return [];
}
};
export const useWeblateStats = () => {
return useQuery({
queryKey: ["weblate-stats"],
queryFn: () => fetchWeblateStats(),
staleTime: 10 * 60 * 1000, // 10 minutes - data considered fresh
gcTime: 10 * 60 * 1000, // 10 minutes - cache persists
retry: 1,
refetchOnWindowFocus: false,
refetchOnMount: false,
});
};
|