Check-in by ben on 2025-04-17 14:31:41

 Stop caching search results in order to always show up-to-date
 results.

 INSERTED    DELETED
       17         29 src/search/index.dcgi.m4
       17         29 TOTAL over 1 changed file

Index: src/search/index.dcgi.m4
==================================================================
--- src/search/index.dcgi.m4
+++ src/search/index.dcgi.m4
@@ -5,18 +5,16 @@
#
# Show search results

include(src/config.awk)
incl(src/api.awk)
-incl(src/cache.awk)
incl(src/cgi.awk)
-incl(src/sqlite.awk)
incl(src/util.awk)

function main(search,     cmd, count, creator, descr, field, fields, i,
-    iaout, id, jsout, label, numfound, order, order_names, output,
-    page, rows, searchstr, signature, sort_param, str, title, type, url)
+    iaout, id, jsout, label, numfound, order, order_names, page, rows,
+    searchstr, sort_param, title, type, url)
{
    order_names["addeddate"] = "addeddate"
    order_names["collection_size"] = "collection_size"
    order_names["createddate"] = "createddate"
    order_names["creator"] = "creatorSorter"
@@ -65,18 +63,10 @@
            order = "nav_order desc"
            sort_param = "sort" order
        }
    }

-    signature = sprintf("search/%s/%s", input, searchstr)
-    str = cache_init(signature)
-    if (length(str) > 0) {
-        print str
-        return
-    }
-
-    output = cache_begin()
    iaout = gettemp()
    jsout = gettemp()

    # get search results

@@ -117,26 +107,25 @@

    if (search ~ /^@/) {
        numfound++
    }
    if (numfound == 0) {
-        print "Your search did not match any items in the Archive." >>output
-        print "Try different keywords or a more general search." >>output
-        print "" >>output
-        printf "[1|PHAROS|%s|%s|%s]\n", cgipath, server, port >>output
-        cache_end()
+        print "Your search did not match any items in the Archive."
+        print "Try different keywords or a more general search."
+        print ""
+        printf "[1|PHAROS|%s|%s|%s]\n", cgipath, server, port
        unlink(jsout)
        unlink(iaout)
        return
    } else {
        pages = int(numfound / rows)
        if (numfound % rows != 0) {
            pages++
        }
        printf "# %s search results, page %d of %d\n", numfound,
-            page, pages >>output
-        print "" >>output
+            page, pages
+        print ""
    }

    # format search results as a gopher directory (menu)
    FS = "\t"
    creator = ""
@@ -146,11 +135,11 @@
    type = ""
    count = 0

    if (search ~ /^@/) {
        printf "[1|Account %s|%s/account/%s|%s|%s]\n", search, cgipath,
-           search, server, port >>output
+           search, server, port
    }

    while ((getline <jsout) > 0) {
        if ($1 == ".response.docs[].creator" && $2 == "s") {
            creator = $3
@@ -171,54 +160,53 @@
                label = sprintf("[%s] %s", mediatype[type],
                    gph_encode(shorten(title, 58)))
            }
            if (type == "collection") {
                printf "[1|%s|%s/search/%%09collection:(%s)|%s|%s]\n",
-                    label, cgipath, id, server, port >>output
+                    label, cgipath, id, server, port
            } else {
                printf "[1|%s|%s/details/%s|%s|%s]\n", label, cgipath,
-                   id, server, port >>output
+                   id, server, port
            }
            creator = ""
            descr = ""
            id = ""
            type = ""
        }
    }
    close(jsout)

-    print "" >>output
+    print ""

    # only show "page back" if the user is past page 1
    if (page > 1) {
        printf "[1|[<<] Page %d|%s/search/page%d/rows%d/%s%%09%s|%s|%s]\n",
            page - 1, cgipath, page - 1, rows, sort_param, search,
-            server, port >>output
+            server, port
    }

    # only show "next page" if the current page is completely full
    if (count == rows) {
        printf "[1|[>>] Page %d|%s/search/page%d/rows%d/%s%%09%s|%s|%s]\n",
            page + 1, cgipath, page + 1, rows, sort_param, search,
-            server, port >>output
+            server, port
    }

    # only show "sort" if there's more than one item to sort
    if (count > 1) {
        printf "[1|[^v] Sort|%s/sort/%%09%s|%s|%s]\n", cgipath, search,
-            server, port >>output
+            server, port
    }

    # only show "search within list" if there's multiple pages of results
    if (numfound > rows) {
        printf "[1|[\\/] Filter results|%s/wizard/step1/%s|%s|%s]\n",
-            cgipath, search, server, port >>output
+            cgipath, search, server, port
    }

-    printf "[1|PHAROS|%s|%s|%s]\n", cgipath, server, port >>output
+    printf "[1|PHAROS|%s|%s|%s]\n", cgipath, server, port

-    cache_end()
    unlink(jsout)
    unlink(iaout)
    exit 0
}