Nakodo has two screens that count the same rows. The campaigns list shows a card per campaign with found, fit, contacted and replied on it. A campaign's own page shows a funnel: found, fit, waiting, contacted, plus how many results are still being checked and, on the free plan, how many are scored but hidden.
Same words, same table, two completely different queries, because one needs a number per campaign in a list and the other needs six numbers for one campaign. That is the situation where a codebase grows two definitions of "fit" and nobody notices for a month. Our defence is that neither screen contains a definition. Both import the same SQL fragments out of src/lib/queries.ts , and the fragments are functions of a table alias:
const fitSql = ( alias : string , cap : number | null , scope : SQL ) => sql ` ${ shownSql ( alias , cap , scope )} and ${ sql . raw ( fitCondition ( alias ))} ` ;
// Fits Nakodo can still write to: a published email, not skipped, and no // conversation in this campaign yet.…