feat: Remove new SMWS bottles from recent report

This commit is contained in:
Brennan Wilkes (Text Groove) 2026-02-09 21:51:57 -08:00
parent 9cb9cd5b61
commit 01624daf7f

View file

@ -283,7 +283,6 @@ function main() {
const items = []; const items = [];
const commits = headSha ? logDbCommitsSince(sinceIso) : []; const commits = headSha ? logDbCommitsSince(sinceIso) : [];
const pairs = []; const pairs = [];
if (commits.length) { if (commits.length) {
@ -315,6 +314,18 @@ function main() {
}); });
} }
function isSmwsBottle(storeLabel, it) {
const hay = [
storeLabel,
it?.name,
it?.url,
]
.map((x) => String(x || ""))
.join(" | ")
.toLowerCase();
return hay.includes("smws") || hay.includes("scotch malt whisky society");
}
for (const p of pairs) { for (const p of pairs) {
const fromSha = p.fromSha; const fromSha = p.fromSha;
const toSha = p.toSha; const toSha = p.toSha;
@ -336,7 +347,6 @@ function main() {
nextObj = gitShowJson(toSha, file); nextObj = gitShowJson(toSha, file);
} }
// NEW: if the DB file itself doesn't exist at "to", skip (prevents mass "removed")
const nextExists = const nextExists =
toSha === "WORKTREE" toSha === "WORKTREE"
? fs.existsSync(path.join(repoRoot, file)) ? fs.existsSync(path.join(repoRoot, file))
@ -345,19 +355,32 @@ function main() {
if (!prevObj && !nextObj) continue; if (!prevObj && !nextObj) continue;
const storeLabel = String(nextObj?.storeLabel || nextObj?.store || prevObj?.storeLabel || prevObj?.store || ""); const storeLabel = String(
const categoryLabel = String(nextObj?.categoryLabel || nextObj?.category || prevObj?.categoryLabel || prevObj?.category || ""); nextObj?.storeLabel ||
nextObj?.store ||
prevObj?.storeLabel ||
prevObj?.store ||
""
);
const categoryLabel = String(
nextObj?.categoryLabel ||
nextObj?.category ||
prevObj?.categoryLabel ||
prevObj?.category ||
""
);
// NEW FEATURE:
// If this DB file did not exist at fromSha, then treat it as a "new store/category file"
// and DO NOT emit its "new"/"restored" items into recent.json (frontpage).
// (Report text is unaffected elsewhere.)
const isNewStoreFile = const isNewStoreFile =
Boolean(fromSha) && Boolean(fromSha) &&
!gitFileExistsAtSha(fromSha, file) && !gitFileExistsAtSha(fromSha, file) &&
(toSha === "WORKTREE" ? fs.existsSync(path.join(repoRoot, file)) : gitFileExistsAtSha(toSha, file)); (toSha === "WORKTREE"
? fs.existsSync(path.join(repoRoot, file))
: gitFileExistsAtSha(toSha, file));
let { newItems, restoredItems, removedItems, priceChanges } = diffDb(prevObj, nextObj); let { newItems, restoredItems, removedItems, priceChanges } = diffDb(
prevObj,
nextObj
);
if (isNewStoreFile) { if (isNewStoreFile) {
newItems = []; newItems = [];
@ -365,6 +388,7 @@ function main() {
} }
for (const it of newItems) { for (const it of newItems) {
if (isSmwsBottle(storeLabel, it)) continue;
items.push({ items.push({
ts, ts,
date: d, date: d,
@ -433,7 +457,6 @@ function main() {
}); });
} }
} }
} }
items.sort((a, b) => String(b.ts).localeCompare(String(a.ts))); items.sort((a, b) => String(b.ts).localeCompare(String(a.ts)));