[object Object]

โ† back to AsSeenInMovies

asseeninmovies: GET /random/movie and /random/person โ€” 302 to a random poster-having movie or headshot-having person, fast (random() over partial idx_*_has_poster) + ๐ŸŽฒ dice icon in nav header. 'I'm feeling lucky' for the catalog.

b8cbc446eb402d85caa6a61428f3ecbc2ca43f26 ยท 2026-05-12 19:11:55 -0700 ยท SteveStudio2

Files touched

Diff

commit b8cbc446eb402d85caa6a61428f3ecbc2ca43f26
Author: SteveStudio2 <stevestudio2@SteveStacStudio.lan>
Date:   Tue May 12 19:11:55 2026 -0700

    asseeninmovies: GET /random/movie and /random/person โ€” 302 to a random poster-having movie or headshot-having person, fast (random() over partial idx_*_has_poster) + ๐ŸŽฒ dice icon in nav header. 'I'm feeling lucky' for the catalog.
---
 server.js | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/server.js b/server.js
index 53fd4d5..d7b11a0 100644
--- a/server.js
+++ b/server.js
@@ -930,6 +930,7 @@ ${headExtras}
     <a href="/spotted">Spotted</a>
     <a href="/spotted/submit">Submit</a>
     <a href="/search">Search</a>
+    <a href="/random/movie" title="Random movie">๐ŸŽฒ</a>
   </nav>
 </header>
 <main>${body}</main>
@@ -1651,6 +1652,25 @@ app.get('/sitemap.xml', async (_req, res) => {
   }
 });
 
+// /random/movie + /random/person โ€” pick a random visually-rich row and 302
+// to its detail page. Useful for "I'm feeling lucky" exploration. Limits
+// scope to the partial idx_*_has_poster / has_headshot indexes so the
+// random pick stays fast (TABLESAMPLE on poster-having only).
+app.get('/random/movie', async (_req, res) => {
+  try {
+    const r = await pool.query(`SELECT id FROM asim_movies WHERE poster_url IS NOT NULL ORDER BY random() LIMIT 1`);
+    if (!r.rows[0]) return res.redirect('/movies');
+    res.redirect(`/movie/${r.rows[0].id}`);
+  } catch (_e) { res.redirect('/movies'); }
+});
+app.get('/random/person', async (_req, res) => {
+  try {
+    const r = await pool.query(`SELECT id FROM asim_people WHERE headshot_url IS NOT NULL ORDER BY random() LIMIT 1`);
+    if (!r.rows[0]) return res.redirect('/people');
+    res.redirect(`/person/${r.rows[0].id}`);
+  } catch (_e) { res.redirect('/people'); }
+});
+
 // Bots and link previewers that don't honor <link rel="icon"> in the head
 // still GET /favicon.ico โ€” serve the same inline SVG so server logs don't
 // fill with 404s and previews show the brand mark.

โ† 592a2e7 asseeninmovies: /api/health perf โ€” pull counts from _homeCac  ยท  back to AsSeenInMovies  ยท  asseeninmovies: branded 404 โ€” was leaking stock Express 'Can 56476af โ†’