172
173/**
174 * Get database statistics for the homepage
175 */
176export async function getSearchStats(): Promise<{
837 const offset = (page - 1) * pageSize;
838
839 // Start all database queries in parallel
840 // 1. Launch count queries
841 const countsPromise = Promise.all([
924 );
925
926 // Wait for all database operations to complete in parallel
927 const [
928 [totalFileResults, totalProjectResults, totalUserResults],
1211 <a href="?q=fetch" className="example-link">fetch</a>
1212 <a href="?q=api" className="example-link">api</a>
1213 <a href="?q=database" className="example-link">database</a>
1214 <a href="?q=image" className="example-link">image</a>
1215 <a href="?q=function" className="example-link">function</a>
1356 <a href="?q=fetch" className="example-link">fetch</a>
1357 <a href="?q=api" className="example-link">api</a>
1358 <a href="?q=database" className="example-link">database</a>
1359 <a href="?q=image" className="example-link">image</a>
1360 <a href="?q=function" className="example-link">function</a>
77 const needFullDocsData = searchTerm && (resultType === "docs" || format.toLowerCase() === "json");
78
79 // Run database search in parallel with appropriate docs search
80 const [searchResponse, docsResult] = await Promise.all([
81 // Database search for files, projects, users
82 searchTerm
83 ? searchFileContentWithContext(searchTerm, 2, page, pageSize, resultType !== "docs" ? resultType : undefined) // Show 2 lines of context
120 };
121
122 // Only get database stats when needed (no query or empty results)
123 const totalResults = combinedResponse.totalFileResults +
124 combinedResponse.totalProjectResults +
72 const needFullDocsData = searchTerm && (resultType === "docs" || format.toLowerCase() === "json");
73
74 // Run database search in parallel with appropriate docs search
75 const [searchResponse, docsResult] = await Promise.all([
76 // Database search for files, projects, users
77 searchTerm
78 ? searchFileContentWithContext(searchTerm, 2, page, pageSize, resultType !== "docs" ? resultType : undefined) // Show 2 lines of context
115 };
116
117 // Only get database stats when needed (no query or empty results)
118 const totalResults = combinedResponse.totalFileResults
119 + combinedResponse.totalProjectResults
172
173/**
174 * Get database statistics for the homepage
175 */
176export async function getSearchStats(): Promise<{
837 const offset = (page - 1) * pageSize;
838
839 // Start all database queries in parallel
840 // 1. Launch count queries
841 const countsPromise = Promise.all([
924 );
925
926 // Wait for all database operations to complete in parallel
927 const [
928 [totalFileResults, totalProjectResults, totalUserResults],
1211 <a href="?q=fetch" className="example-link">fetch</a>
1212 <a href="?q=api" className="example-link">api</a>
1213 <a href="?q=database" className="example-link">database</a>
1214 <a href="?q=image" className="example-link">image</a>
1215 <a href="?q=function" className="example-link">function</a>
1356 <a href="?q=fetch" className="example-link">fetch</a>
1357 <a href="?q=api" className="example-link">api</a>
1358 <a href="?q=database" className="example-link">database</a>
1359 <a href="?q=image" className="example-link">image</a>
1360 <a href="?q=function" className="example-link">function</a>
172
173/**
174 * Get database statistics for the homepage
175 */
176export async function getSearchStats(): Promise<{
837 const offset = (page - 1) * pageSize;
838
839 // Start all database queries in parallel
840 // 1. Launch count queries
841 const countsPromise = Promise.all([
924 );
925
926 // Wait for all database operations to complete in parallel
927 const [
928 [totalFileResults, totalProjectResults, totalUserResults],
1211 <a href="?q=fetch" className="example-link">fetch</a>
1212 <a href="?q=api" className="example-link">api</a>
1213 <a href="?q=database" className="example-link">database</a>
1214 <a href="?q=image" className="example-link">image</a>
1215 <a href="?q=function" className="example-link">function</a>
1356 <a href="?q=fetch" className="example-link">fetch</a>
1357 <a href="?q=api" className="example-link">api</a>
1358 <a href="?q=database" className="example-link">database</a>
1359 <a href="?q=image" className="example-link">image</a>
1360 <a href="?q=function" className="example-link">function</a>
77 const needFullDocsData = searchTerm && (resultType === "docs" || format.toLowerCase() === "json");
78
79 // Run database search in parallel with appropriate docs search
80 const [searchResponse, docsResult] = await Promise.all([
81 // Database search for files, projects, users
82 searchTerm
83 ? searchFileContentWithContext(searchTerm, 2, page, pageSize, resultType !== "docs" ? resultType : undefined) // Show 2 lines of context
120 };
121
122 // Only get database stats when needed (no query or empty results)
123 const totalResults = combinedResponse.totalFileResults +
124 combinedResponse.totalProjectResults +
12 getAllMemories,
13 updateMemory,
14} from "./database/queries.ts";
15import { type Memory } from "../shared/types.ts";
16import { blob } from "https://esm.town/v/std/blob";