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