[object Object]

← back to Sample Followup Sweep

watch-sent-stamp: fix Sent search (drop em-dash from subject query) + drop unwritable 2nd Request field (Date-Email-Sent is the marker)

405e7de73b3b144f4c3af4cb338f8214eb8c478b · 2026-08-20 13:07:26 -0700 · Steve

Files touched

Diff

commit 405e7de73b3b144f4c3af4cb338f8214eb8c478b
Author: Steve <steve@designerwallcoverings.com>
Date:   Thu Aug 20 13:07:26 2026 -0700

    watch-sent-stamp: fix Sent search (drop em-dash from subject query) + drop unwritable 2nd Request field (Date-Email-Sent is the marker)
---
 scripts/watch-sent-stamp.mjs | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/scripts/watch-sent-stamp.mjs b/scripts/watch-sent-stamp.mjs
index f4aca9c..b9b92f6 100644
--- a/scripts/watch-sent-stamp.mjs
+++ b/scripts/watch-sent-stamp.mjs
@@ -34,7 +34,7 @@ const pad = n => String(n).padStart(2, '0'); const today = (d => `${pad(d.getMon
 const genv = k => { for (const f of ['/Users/macstudio3/Projects/Designer-Wallcoverings/DW-MCP/.env', '/Users/macstudio3/Projects/george-gmail/.env']) { try { const m = readFileSync(f, 'utf8').match(new RegExp('^' + k + '=(.+)$', 'm')); if (m) return m[1].trim(); } catch {} } return ''; };
 let auth = genv('GEORGE_BASIC_AUTH'); if (!auth.includes(':')) auth = 'admin:' + genv('GEORGE_BASIC_AUTH_PASS');
 auth = 'Basic ' + Buffer.from(auth).toString('base64');
-function gsearch(q) { return new Promise(res => { const p = '/api/search?account=info&maxResults=30&q=' + encodeURIComponent(q); const rq = http.request({ host: '127.0.0.1', port: 9850, path: p, method: 'GET', headers: { Authorization: auth } }, r => { let d = ''; r.on('data', x => d += x); r.on('end', () => { try { res(JSON.parse(d).messages || JSON.parse(d) || []); } catch { res([]); } }); }); rq.on('error', () => res([])); rq.end(); }); }
+function gsearch(q) { return new Promise(res => { const p = '/api/messages?account=info&maxResults=30&q=' + encodeURIComponent(q); const rq = http.request({ host: '127.0.0.1', port: 9850, path: p, method: 'GET', headers: { Authorization: auth } }, r => { let d = ''; r.on('data', x => d += x); r.on('end', () => { try { const j = JSON.parse(d); res(j.messages || (Array.isArray(j) ? j : [])); } catch { res([]); } }); }); rq.on('error', () => res([])); rq.end(); }); }
 
 async function stampVids(vids) {
   // outstanding (Date WP Sample Sent empty) for these vids in the window → recordIds → stamp
@@ -42,8 +42,8 @@ async function stampVids(vids) {
   for (const vid of vids) {
     const rows = (await fm.findRecords(DB, 'REPORT ON SAMPLES ORDERED', { 'Date WP Sample Sent': '=', vid, 'today for client': WIN }, { limit: 200 }).catch(() => ({ records: [] }))).records;
     for (const r of rows) {
-      // primary: 2nd Request; also stamp the proven Date-Email-Sent field. Separate calls so one bad field can't block the other.
-      await fm.updateRecord(DB, LAYOUT, r.recordId, { [FIELD_2ND]: today }, { dryRun: false }).catch(() => {});
+      // Steve 8/20: the "2nd Request" marker IS the API-writable "Date Email Sent to Vendor after
+      // 10 Days" field (the true 2nd Request date field isn't on any Data-API layout).
       await fm.updateRecord(DB, LAYOUT, r.recordId, { [FIELD_SENT]: today }, { dryRun: false }).catch(() => {});
       n++;
     }
@@ -53,7 +53,9 @@ async function stampVids(vids) {
 
 async function pass() {
   const seen = readJSON(LEDGER, {});
-  const msgs = await gsearch('in:sent subject:"Sample Follow-Up — Outstanding Memos" newer_than:1d');
+  // NB: the em-dash in the full subject breaks Gmail matching over HTTP — match the ASCII prefix.
+  const msgs = await gsearch('in:sent subject:"Sample Follow-Up" newer_than:1d');
+  if (process.env.DEBUG) console.log(`  [debug] gsearch → ${msgs.length} msg(s); ledger has ${Object.keys(seen).length}`);
   let acted = 0;
   for (const m of msgs) {
     if (seen[m.id]) continue;

← 55d6a33 auto-data-snapshot: 2026-08-20T11:21:15 (1 data files) — dat  ·  back to Sample Followup Sweep  ·  sample-followup: self-updating suppression (live info@ Sent 2dfaa6c →