mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-12 20:35:24 +00:00
no-store caching strategy
This commit is contained in:
parent
35edfa0a64
commit
700c5f7522
5 changed files with 21 additions and 26 deletions
|
|
@ -1,5 +1,3 @@
|
|||
'use client';
|
||||
|
||||
import Image from "next/image";
|
||||
import logoDark from "../../public/sb_logo_dark_large.png";
|
||||
import logoLight from "../../public/sb_logo_light_large.png";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
'use client';
|
||||
|
||||
import { Suspense } from "react";
|
||||
import { NavigationMenu } from "../navigationMenu";
|
||||
import { RepositoryTable } from "./repositoryTable";
|
||||
|
||||
|
|
@ -7,7 +6,9 @@ export default function ReposPage() {
|
|||
return (
|
||||
<div className="h-screen flex flex-col items-center">
|
||||
<NavigationMenu />
|
||||
<RepositoryTable />
|
||||
<Suspense fallback={<div>Loading...</div>}>
|
||||
<RepositoryTable />
|
||||
</Suspense>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
@ -1,25 +1,17 @@
|
|||
'use client';
|
||||
|
||||
import { DataTable } from "@/components/ui/data-table";
|
||||
import { columns, RepositoryColumnInfo } from "./columns";
|
||||
import { listRepositories } from "@/lib/server/searchService";
|
||||
import { isServiceError } from "@/lib/utils";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useMemo } from "react";
|
||||
import { getRepos } from "../api/(client)/client";
|
||||
|
||||
export const RepositoryTable = () => {
|
||||
const { data: _repos } = useQuery({
|
||||
queryKey: ["repos"],
|
||||
queryFn: () => getRepos(),
|
||||
enabled: typeof window !== "undefined",
|
||||
});
|
||||
export const RepositoryTable = async () => {
|
||||
const _repos = await listRepositories();
|
||||
|
||||
const repos = useMemo(() => {
|
||||
if (isServiceError(_repos)) {
|
||||
return [];
|
||||
}
|
||||
if (isServiceError(_repos)) {
|
||||
return <div>Error fetching repositories</div>;
|
||||
}
|
||||
|
||||
return _repos?.List.Repos.map((repo): RepositoryColumnInfo => ({
|
||||
const repos = _repos.List.Repos.map((repo): RepositoryColumnInfo => {
|
||||
return {
|
||||
name: repo.Repository.Name,
|
||||
branches: repo.Repository.Branches.map((branch) => {
|
||||
return {
|
||||
|
|
@ -34,10 +26,10 @@ export const RepositoryTable = () => {
|
|||
latestCommit: repo.Repository.LatestCommitDate,
|
||||
indexedFiles: repo.Stats.Documents,
|
||||
commitUrlTemplate: repo.Repository.CommitURLTemplate,
|
||||
})).sort((a, b) => {
|
||||
return new Date(b.lastIndexed).getTime() - new Date(a.lastIndexed).getTime();
|
||||
}) ?? [];
|
||||
}, [_repos]);
|
||||
}
|
||||
}).sort((a, b) => {
|
||||
return new Date(b.lastIndexed).getTime() - new Date(a.lastIndexed).getTime();
|
||||
});
|
||||
|
||||
return (
|
||||
<DataTable
|
||||
|
|
|
|||
|
|
@ -74,7 +74,8 @@ export const listRepositories = async (): Promise<ListRepositoriesResponse | Ser
|
|||
const listResponse = await zoektFetch({
|
||||
path: "/api/list",
|
||||
body,
|
||||
method: "POST"
|
||||
method: "POST",
|
||||
cache: "no-store",
|
||||
});
|
||||
|
||||
if (!listResponse.ok) {
|
||||
|
|
|
|||
|
|
@ -5,12 +5,14 @@ interface ZoektRequest {
|
|||
path: string,
|
||||
body: string,
|
||||
method: string,
|
||||
cache?: RequestCache,
|
||||
}
|
||||
|
||||
export const zoektFetch = async ({
|
||||
path,
|
||||
body,
|
||||
method,
|
||||
cache,
|
||||
}: ZoektRequest) => {
|
||||
const start = Date.now();
|
||||
|
||||
|
|
@ -22,6 +24,7 @@ export const zoektFetch = async ({
|
|||
"Content-Type": "application/json",
|
||||
},
|
||||
body,
|
||||
cache,
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue