← back to Dw Yolo Loop

scripts/trending-2026/README.md

40 lines

# Trending Wallcovering Collection 2026 — daily tag reconciler

Keeps the Shopify tag **`Trending Wallcovering Collection 2026`** on exactly the right
products, every day.

## Rule
Target set (who carries the tag) = the **newest 1000 active products** by created
date — a **hard cap of 1000**, no exceptions.

Artmura is included only when its products naturally fall inside that newest 1000.
Today all 161 Artmura sit well within the newest 1000, so they're all tagged.

## What each run does
Re-derives the target via GraphQL search (no full-catalog scan), then:
- **adds** the tag to target products missing it (new arrivals entering the top 500)
- **removes** the tag from any product (any status) that has it but is no longer in
  the target (aged out / archived)

Idempotent and safe to re-run. Tag search is eventually-consistent, so the
post-run count may lag for a minute before settling.

## Run manually
```sh
node trending-tag-sync.cjs --dry-run      # preview +add / -remove counts
node trending-tag-sync.cjs                # apply
node trending-tag-sync.cjs --top 1000 --conc 6
```

## Cron
LaunchAgent `com.steve.dw-trending-2026` (Mac2) runs it **daily at 05:00**.
- plist: `~/Library/LaunchAgents/com.steve.dw-trending-2026.plist`
- logs: `sync.log` (per-run summary), `cron.out.log` / `cron.err.log` (launchd)
- reload: `launchctl kickstart -k gui/$(id -u)/com.steve.dw-trending-2026`

## Cost
$0 — Shopify Admin API has no per-call charge.

## Token
Reads `SHOPIFY_ADMIN_TOKEN` from `~/Projects/secrets-manager/.env` (has write_products).