You can access search results via JSON API by adding format=json
to your query:
https://codesearch.val.run/image-url.jpg%20%22Optional%20title%22?q=fetch&page=10&format=json
For typeahead suggestions, use the /typeahead
endpoint:
https://codesearch.val.run/typeahead?q=fetch
Returns an array of strings in format "username" or "username/projectName"
Found 8302 results for "fetch"(649ms)
230const [selectedAuthorName, setSelectedAuthorName] = useState("");
231232// Function to fetch the detailed report
233const fetchDetailedReport = async () => {
234// setWeeklySummary(null); // REMOVED: Don't clear summary when fetching detailed
235setDetailedReport(null); // Clear previous detailed data while fetching
236try {
237const response = await fetch("/generate-report"); // Assuming this endpoint provides detailed data
238const data = await response.json();
239setDetailedReport(data);
240} catch (error) {
241console.error("Failed to fetch detailed report:", error);
242alert("Failed to fetch detailed report.");
243}
244};
245246// Function to fetch the weekly summary report
247const fetchWeeklySummary = async () => {
248// setDetailedReport(null); // REMOVED: Don't clear detailed when fetching summary
249setWeeklySummary(null); // Clear previous summary data while fetching
250try {
251// This fetches the summary data for the last 7 days for all users
252// Assumes the /generate-weekly-summary endpoint exists on the server
253const response = await fetch("/generate-weekly-summary");
254const data = await response.json(); // Assuming data is an array like [{ author: 'User A', submittedArticles: 10, monitoredMedia: 5 }, ...]
255setWeeklySummary(data);
256} catch (error) {
257console.error("Failed to fetch weekly summary:", error);
258alert("Failed to fetch weekly summary.");
259}
260};
261262// Effect to fetch data when the view changes or component mounts
263useEffect(() => {
264// Fetch data for the current view
265if (currentView === "detailed") {
266// Only fetch detailed if it's not already loaded (optional optimization)
267// if (!detailedReport) {
268fetchDetailedReport();
269// }
270} else if (currentView === "summary") {
271// Only fetch summary if it's not already loaded (optional optimization)
272// if (!weeklySummary) {
273fetchWeeklySummary();
274// }
275}
337// so it should contain data if the detailed tab was visited or on initial load.
338if (!detailedReport || !detailedReport.newsArticles || !detailedReport.mediaEntries) {
339// This alert is still necessary if the initial fetch failed or hasn't completed yet
340alert(
341"Detailed report data is not available to show author details. Please try switching to the Detailed Report tab first.",
653</>
654)
655: <p>Fetching detailed report...</p>} {/* Loading indicator */}
656</>
657)}
755</>
756)
757: <p>Fetching weekly summary...</p>} {/* Loading indicator */}
758</>
759)}
42const handleLogin = async (username, password) => {
43try {
44const response = await fetch("/login", {
45method: "POST",
46headers: { "Content-Type": "application/json" },
407}
408409if (path === "/fetch-news" && method === "GET") {
410const newsArticles = await sqlite.execute(`SELECT * FROM ${KEY}_news_articles ORDER BY created_at DESC`);
411return new Response(JSON.stringify({ articles: newsArticles.rows }), {
414}
415416if (path === "/fetch-media" && method === "GET") {
417const mediaEntries = await sqlite.execute(`SELECT * FROM ${KEY}_media_monitoring ORDER BY created_at DESC`);
418return new Response(JSON.stringify({ entries: mediaEntries.rows }), {
506507if (result.rowsAffected > 0) {
508// Fetch the updated article to return it to the client
509const updatedArticle = await sqlite.execute(`SELECT * FROM ${KEY}_news_articles WHERE id = ?`, [id]);
510517// This case should ideally not happen if rowsAffected > 0, but good for robustness
518return new Response(
519JSON.stringify({ success: false, message: "Article updated but could not be refetched" }),
520{
521status: 500, // Internal Server Error
568569if (result.rowsAffected > 0) {
570// Fetch the updated entry to return it
571const updatedEntry = await sqlite.execute(`SELECT * FROM ${KEY}_media_monitoring WHERE id = ?`, [id]);
572return new Response(JSON.stringify({ success: true, entry: updatedEntry.rows[0] }), {
603const sevenDaysAgoISO = sevenDaysAgo.toISOString(); // e.g., "2023-10-27T10:00:00.000Z"
604605// Fetch news article counts per author in the last 7 days
606const newsCountsResult = await sqlite.execute(
607`
614);
615616// Fetch media monitoring counts per author in the last 7 days
617const mediaCountsResult = await sqlite.execute(
618`