Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Trim the search sync prose

Rafiff0d6bef469f
diff --git a/apps/web/.env.example b/apps/web/.env.example
index 71df24de99..82f07db7ef 100644
--- a/apps/web/.env.example
+++ b/apps/web/.env.example
@@ -24,11 +24,6 @@ UPSTASH_REDIS_REST_URL=
UPSTASH_REDIS_REST_TOKEN=
# Full-text partner search. Unset falls back to the database search path.
-# The key alone only starts the index syncs; reads stay on the database until
-# PARTNER_SEARCH_READ_ENABLED is "true". Set the key once and leave it set —
-# only the live sync hooks can remove a document, so any window where the app
-# runs without it strands the enrollments deleted meanwhile. Turning search off
-# means clearing the read flag, never the key.
TURBOPUFFER_API_KEY=
PARTNER_SEARCH_READ_ENABLED=
diff --git a/apps/web/lib/actions/partners/onboard-partner.ts b/apps/web/lib/actions/partners/onboard-partner.ts
index ddf2e683c7..f1f39ec3dd 100644
--- a/apps/web/lib/actions/partners/onboard-partner.ts
+++ b/apps/web/lib/actions/partners/onboard-partner.ts
@@ -128,7 +128,7 @@ export const onboardPartnerAction = authUserActionClient
// Onboarding sets name, country, and description, all of which the
// document carries. Runs after completeProgramApplications above, which
- // queues its own sync for the enrollments it creates; both collapse on
+ // queues its own sync for the enrollments it creates. Both collapse on
// the same partner, and re-indexing twice is harmless either way.
queuePartnerSearchSync({ partnerIds: [updatedPartner.id] }),
]),
diff --git a/apps/web/lib/api/links/bulk-update-links.ts b/apps/web/lib/api/links/bulk-update-links.ts
index 6e07851224..05cda53fa8 100644
--- a/apps/web/lib/api/links/bulk-update-links.ts
+++ b/apps/web/lib/api/links/bulk-update-links.ts
@@ -44,7 +44,7 @@ export async function bulkUpdateLinks(
const imageUrlNonce = nanoid(7);
// The bulk payload is createLinkBodySchema minus domain/key/externalId, and
- // that omit list does not drop `partnerId` or `programId` — so a bulk update
+ // that omit list does not drop `partnerId` or `programId`, so a bulk update
// can move links between partners. Read the current owners first, because
// after the write they are unrecoverable and syncing only the new owner
// would leave the links searchable under a partner who no longer has them.
diff --git a/apps/web/lib/api/partners/queue-partner-search-sync.ts b/apps/web/lib/api/partners/queue-partner-search-sync.ts
index e4f99b97db..299b84301f 100644
--- a/apps/web/lib/api/partners/queue-partner-search-sync.ts
+++ b/apps/web/lib/api/partners/queue-partner-search-sync.ts
@@ -31,7 +31,7 @@ export const PARTNER_SEARCH_SYNC_DELAY_SECONDS = 5;
*
* Half the deduplication window rather than all of it. Deduplication only ever
* collapses repeat edits to the *same* partner, so the delay is not what keeps
- * a bulk link change cheap — chunking and flow control do that. Buying a little
+ * a bulk link change cheap. Chunking and flow control do that. Buying a little
* more collapse by sitting at the window boundary would trade a real margin for
* a rare case.
*
@@ -78,7 +78,7 @@ function unique(values: string[] | undefined): string[] {
*
* A delay at or past the deduplication window gets no key at all. QStash would
* have forgotten the ID before the first message fired, so every edit would
- * write anyway; sending a key regardless would just make the caller believe in
+ * write anyway, and sending a key regardless would just make the caller believe in
* a collapse that is not happening. Failing openly beats failing quietly.
*/
function buildDeduplicationId(
@@ -105,7 +105,7 @@ function buildDeduplicationId(
*
* Never throws. A search index that falls behind costs relevance ranking and
* the wider field coverage, which the read path already degrades to when no
- * provider is configured; a partner mutation failing because a queue was
+ * provider is configured. A partner mutation failing because a queue was
* unreachable would be a far worse outcome. Job dispatch already persists to
* the database when QStash is unavailable, so reaching the catch here means
* both paths failed, and the reconciliation sweep is what recovers from it.
diff --git a/apps/web/lib/api/partners/search/provider.ts b/apps/web/lib/api/partners/search/provider.ts
index 34ba37cd3c..3d5095ac74 100644
--- a/apps/web/lib/api/partners/search/provider.ts
+++ b/apps/web/lib/api/partners/search/provider.ts
@@ -14,10 +14,10 @@ let cachedSearchProvider: PartnerSearchProvider | null = null;
* an unset key costs the wider field coverage rather than the partner list.
*
* Once set in an environment that serves traffic, leave it set. Removing a
- * document is something only the live sync hooks can do — the backfill and the
- * sweep upsert and never delete — so any window where the app runs with this
- * unset turns every enrollment deleted during it into a document nothing can
- * remove short of rebuilding the namespace.
+ * document is something only the live sync hooks can do, because the backfill
+ * and the sweep upsert and never delete. Any window where the app runs with
+ * this unset therefore turns every enrollment deleted during it into a document
+ * nothing can remove short of rebuilding the namespace.
*/
export function getPartnerSearchProvider(): PartnerSearchProvider | null {
if (!process.env.TURBOPUFFER_API_KEY?.trim()) {
@@ -34,16 +34,15 @@ export function getPartnerSearchProvider(): PartnerSearchProvider | null {
* database.
*
* Reads get their own switch so that turning search off never means turning
- * indexing off. That is the whole point: writes stay on from the first day and
- * are never flipped, so the index keeps tracking deletions even while nothing
- * is reading it, and coming back is flipping this one flag rather than
- * rebuilding a namespace.
+ * indexing off. Writes stay on from the first day and are never flipped, so the
+ * index keeps tracking deletions even while nothing is reading it, and coming
+ * back is a matter of setting this flag rather than rebuilding a namespace.
*
- * It also keeps the initial rollout honest. An empty index does not degrade
- * gracefully — a program with no documents yet produces a successful, empty
- * candidate list, which the callers apply as `id IN ()` after clearing the
- * database search predicate, so every query returns nothing. Reads therefore
- * stay off until the backfill has finished.
+ * The same switch is what lets reads stay off until the backfill has finished.
+ * An empty index does not fall back to the database: a program with no
+ * documents yet produces a successful, empty candidate list, which the callers
+ * apply as `id IN ()` after clearing the database search predicate, so every
+ * query returns nothing.
*/
export function isPartnerSearchReadEnabled(): boolean {
return process.env.PARTNER_SEARCH_READ_ENABLED?.trim() === "true";
diff --git a/apps/web/lib/api/partners/search/sync.ts b/apps/web/lib/api/partners/search/sync.ts
index bffef1a823..6a763548cb 100644
--- a/apps/web/lib/api/partners/search/sync.ts
+++ b/apps/web/lib/api/partners/search/sync.ts
@@ -89,7 +89,7 @@ interface FindPartnerSearchSyncEnrollmentIdsOptions {
* touches every program the partner is enrolled in.
*
* Paged by enrollment ID so the caller can resume, because the fan-out is
- * unbounded — a partner enrolled in hundreds of programs produces hundreds of
+ * unbounded: a partner enrolled in hundreds of programs produces hundreds of
* documents from one profile write.
*
* `programId` narrows to a single enrollment per partner, which is what the
diff --git a/apps/web/lib/jobs/handlers/partner-search-sync-job.ts b/apps/web/lib/jobs/handlers/partner-search-sync-job.ts
index 80c9f2347e..ad1600c6d8 100644
--- a/apps/web/lib/jobs/handlers/partner-search-sync-job.ts
+++ b/apps/web/lib/jobs/handlers/partner-search-sync-job.ts
@@ -20,7 +20,7 @@ const SYNC_PARALLELISM = 20;
* Two shapes, because the two kinds of change have different blast radii.
*
* `enrollments` carries IDs the caller already knows, and is the only shape
- * that can express a deletion — the handler discovers an enrollment is gone by
+ * that can express a deletion, because the handler discovers an enrollment is gone by
* failing to read it back.
*
* `partners` is for changes that fan out beyond one enrollment (a profile edit,
@@ -91,7 +91,7 @@ export const partnerSearchSyncJob = defineJob({
}
// These IDs came from the database a moment ago, so the sync will upsert
- // rather than delete them — unless the enrollment disappeared in between,
+ // rather than delete them, unless the enrollment disappeared in between,
// in which case removing it from the index is the right outcome anyway.
const { upserted, deleted } = await syncPartnerSearchDocuments({
enrollmentIds,
diff --git a/apps/web/lib/partners/sync-partner-identity.ts b/apps/web/lib/partners/sync-partner-identity.ts
index 3816df2578..ee8782e4c1 100644
--- a/apps/web/lib/partners/sync-partner-identity.ts
+++ b/apps/web/lib/partners/sync-partner-identity.ts
@@ -103,7 +103,7 @@ export async function syncNameAndImageToPartner({
},
});
- // Only the name reaches the document; an image-only sync changes nothing the
+ // Only the name reaches the document, so an image-only sync changes nothing the
// index holds, so it is not worth a queue.
if (hasNameUpdate && name) {
await queuePartnerSearchSync({ partnerIds: [partnerId] });
diff --git a/apps/web/scripts/partners/backfill-partner-search.ts b/apps/web/scripts/partners/backfill-partner-search.ts
index e880b1840a..ea3c1de590 100644
--- a/apps/web/scripts/partners/backfill-partner-search.ts
+++ b/apps/web/scripts/partners/backfill-partner-search.ts
@@ -99,7 +99,7 @@ function createProgressReporter({
const elapsedSec = ((Date.now() - startTime) / 1000).toFixed(1);
// `totalDocuments` is a snapshot from before the run, so enrollments
- // written while it pages can push the final chunk past it; the percentage
+ // written while it pages can push the final chunk past it, so the percentage
// is clamped rather than reporting >100%.
const progress =
totalDocuments === null
diff --git a/apps/web/tests/partners/queue-partner-search-sync.test.ts b/apps/web/tests/partners/queue-partner-search-sync.test.ts
index 4604e6e99e..aac17b2e81 100644
--- a/apps/web/tests/partners/queue-partner-search-sync.test.ts
+++ b/apps/web/tests/partners/queue-partner-search-sync.test.ts
@@ -267,7 +267,7 @@ describe("queuePartnerSearchSyncForLinks", () => {
});
});
-describe("queuePartnerSearchSyncForLinks — ownership transfer", () => {
+describe("queuePartnerSearchSyncForLinks: ownership transfer", () => {
beforeEach(() => {
mocks.getPartnerSearchProvider
.mockReset()