feat(linkedin): auto-prune content history entries older than 90 days
Adds pruneContentHistory call to session-start.mjs after week rollover. Uses dynamic import() for state-updater.mjs. Non-critical: silently skipped on failure. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
1474948ef8
commit
d7a562fc45
1 changed files with 13 additions and 0 deletions
|
|
@ -149,6 +149,19 @@ if (existsSync(STATE_FILE)) {
|
||||||
weekResetNote = `Warning: Week rollover failed (${err.message}). Manual reset may be needed.`;
|
weekResetNote = `Warning: Week rollover failed (${err.message}). Manual reset may be needed.`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Auto-prune Recent Posts entries older than 90 days
|
||||||
|
try {
|
||||||
|
const currentState = readFileSync(STATE_FILE, 'utf-8');
|
||||||
|
const { pruneContentHistory } = await import('./state-updater.mjs');
|
||||||
|
const pruneResult = pruneContentHistory(currentState, 90);
|
||||||
|
if (pruneResult && pruneResult.pruned > 0) {
|
||||||
|
writeFileSync(STATE_FILE, pruneResult.content, 'utf-8');
|
||||||
|
weekResetNote += (weekResetNote ? ' ' : '') + `Auto-pruned ${pruneResult.pruned} posts older than 90 days from Recent Posts.`;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Non-critical: don't block session start on pruning failure
|
||||||
|
}
|
||||||
|
|
||||||
// Build status line
|
// Build status line
|
||||||
let statusLine = `LinkedIn: ${postsThisWeek}/${weeklyGoal} posts this week | Streak: ${currentStreak} days`;
|
let statusLine = `LinkedIn: ${postsThisWeek}/${weeklyGoal} posts this week | Streak: ${currentStreak} days`;
|
||||||
if (lastPostDate && lastPostDate !== 'null') {
|
if (lastPostDate && lastPostDate !== 'null') {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue