feat: configure ready outreach funnel limit

This commit is contained in:
jjbrunton committed 2026-08-09 16:13:58 +01:00
1 parent 22eb32e5bf
commit e9083281a8
15 files changed
+66 -11

No files matched your search

+15 -1
View File
@@ -10,6 +10,7 @@ const AdvancedConfigSchema = z.strictObject({
subreddits: true,
prioritizeRecentPosts: true,
recentWindowMinutes: true,
maxReadyCandidates: true,
}),
openrouter: ConfigSchema.shape.openrouter.omit({ apiKey: true }),
browser: z.strictObject({ sessionDir: z.string() }),
@@ -19,7 +20,13 @@ const AdvancedConfigSchema = z.strictObject({
});
function advancedConfig(ctx: WebContext): z.infer<typeof AdvancedConfigSchema> {
const { subreddits: _subreddits, prioritizeRecentPosts: _prioritize, recentWindowMinutes: _window, ...reddit } = ctx.config.reddit;
const {
subreddits: _subreddits,
prioritizeRecentPosts: _prioritize,
recentWindowMinutes: _window,
maxReadyCandidates: _maxReady,
...reddit
} = ctx.config.reddit;
const { apiKey: _apiKey, ...openrouter } = ctx.config.openrouter;
const { dryRun: _dryRun, ...browser } = ctx.config.browser;
return {
@@ -98,6 +105,12 @@ export function createConfigRouter(ctx: WebContext): Router {
if (typeof updates.reddit.recentWindowMinutes === 'number' && updates.reddit.recentWindowMinutes > 0) {
ctx.runtimeConfig.reddit.recentWindowMinutes = updates.reddit.recentWindowMinutes;
}
if (typeof updates.reddit.maxReadyCandidates === 'number'
&& Number.isInteger(updates.reddit.maxReadyCandidates)
&& updates.reddit.maxReadyCandidates >= 1
&& updates.reddit.maxReadyCandidates <= 500) {
ctx.runtimeConfig.reddit.maxReadyCandidates = updates.reddit.maxReadyCandidates;
}
}
// Mirror into the loaded config so getStats reflects new values.
@@ -107,6 +120,7 @@ export function createConfigRouter(ctx: WebContext): Router {
ctx.config.browser.dryRun = ctx.runtimeConfig.browser.dryRun;
ctx.config.reddit.prioritizeRecentPosts = ctx.runtimeConfig.reddit.prioritizeRecentPosts;
ctx.config.reddit.recentWindowMinutes = ctx.runtimeConfig.reddit.recentWindowMinutes;
ctx.config.reddit.maxReadyCandidates = ctx.runtimeConfig.reddit.maxReadyCandidates;
if (parsedSubreddits?.success) {
const next: SubredditConfig[] = parsedSubreddits.data;