Fix article date extraction to use RSS feed publication dates
Root cause: AI models don't know "today's date" and were defaulting to 2024 Changes: 1. Update extract-article-data.ts to accept RSS pubDate parameter 2. Format RFC 2822 dates from RSS feed to YYYY-MM-DD 3. Pass formatted date directly in AI prompt instead of asking for "today's date" 4. Update auto-add-new-articles.ts to pass pubDate from RSS feed 5. Correct 3 existing articles with wrong dates: - ai-market-research-cfo-scrutiny: 2024-02-14 → 2025-11-10 - leaders-using-ai-daily-scale-3x-faster: 2024-02-13 → 2025-11-10 - team-stopped-questioning-ai: 2024-02-13 → 2025-11-07 Result: - Future articles will have accurate publication dates from RSS feed - No longer depends on AI model's knowledge cutoff - Falls back to system date if RSS feed date is invalid 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
fc46b49b35
commit
303a31123a
|
|
@ -25,7 +25,7 @@ async function main() {
|
|||
console.log(`${'='.repeat(80)}`);
|
||||
|
||||
try {
|
||||
await extractAndAddArticle(article.link);
|
||||
await extractAndAddArticle(article.link, article.pubDate);
|
||||
console.log(`✅ Successfully processed: ${article.title}`);
|
||||
} catch (error) {
|
||||
console.error(`❌ Failed to process "${article.title}":`, error);
|
||||
|
|
|
|||
|
|
@ -206,7 +206,16 @@ function callAnthropicAPI(
|
|||
}
|
||||
|
||||
// TIER 1: Haiku extracts metadata (fast & cheap)
|
||||
async function extractMetadataWithHaiku(articleContent: string, articleUrl: string): Promise<MetadataExtraction> {
|
||||
async function extractMetadataWithHaiku(articleContent: string, articleUrl: string, pubDate?: string): Promise<MetadataExtraction> {
|
||||
let formattedDate = new Date().toISOString().split('T')[0];
|
||||
if (pubDate) {
|
||||
try {
|
||||
formattedDate = new Date(pubDate).toISOString().split('T')[0];
|
||||
} catch (e) {
|
||||
console.warn(`Failed to parse pubDate: ${pubDate}, using system date`);
|
||||
}
|
||||
}
|
||||
|
||||
const prompt = `Extract basic metadata from this article in JSON format.
|
||||
|
||||
Article: ${articleContent.substring(0, 10000)}
|
||||
|
|
@ -214,7 +223,7 @@ Article: ${articleContent.substring(0, 10000)}
|
|||
Return JSON with:
|
||||
- slug: URL-friendly version of title (lowercase, hyphens)
|
||||
- title: Full article title
|
||||
- date: Today's date (YYYY-MM-DD)
|
||||
- date: Publication date in YYYY-MM-DD format (use: ${formattedDate})
|
||||
- description: 2-3 sentence summary
|
||||
- keyPoints: Array of 3-4 main takeaways
|
||||
- topics: Array of 1-3 topic IDs from: STRATEGY, TOOLS, BUSINESS, IMPLEMENTATION, MEASUREMENT
|
||||
|
|
@ -289,7 +298,7 @@ Return ONLY valid JSON:`;
|
|||
return qualityContent;
|
||||
}
|
||||
|
||||
async function extractAndAddArticle(articleUrl: string): Promise<void> {
|
||||
async function extractAndAddArticle(articleUrl: string, pubDate?: string): Promise<void> {
|
||||
console.log(`\n🤖 Processing article: ${articleUrl}`);
|
||||
console.log('💡 Using two-tier optimization: Haiku for metadata, Sonnet for quality\n');
|
||||
|
||||
|
|
@ -300,7 +309,7 @@ async function extractAndAddArticle(articleUrl: string): Promise<void> {
|
|||
console.log(`✅ Fetched ${articleContent.length} characters\n`);
|
||||
|
||||
// TIER 1: Extract metadata with Haiku (cheap & fast)
|
||||
const metadata = await extractMetadataWithHaiku(articleContent, articleUrl);
|
||||
const metadata = await extractMetadataWithHaiku(articleContent, articleUrl, pubDate);
|
||||
console.log(`✅ Metadata extracted: "${metadata.title}"\n`);
|
||||
|
||||
// TIER 2: Extract quality content with Sonnet (using metadata context)
|
||||
|
|
|
|||
|
|
@ -922,7 +922,7 @@ export const ALL_CLAIMS_DATA: ClaimData[] = [
|
|||
{
|
||||
slug: "ai-market-research-cfo-scrutiny",
|
||||
title: "How to Get AI Market Research That Survives CFO Scrutiny",
|
||||
date: "2024-02-14",
|
||||
date: "2025-11-10",
|
||||
featuredClaim: "38% of AI-generated market research contains material factual errors that undermine business decisions.",
|
||||
description: "The article discusses the challenges of AI-generated market research and provides a methodology for creating more accurate and verifiable research reports. It highlights the issues of citation inflation and unfounded projections in AI-generated analyses.",
|
||||
keyPoints: [
|
||||
|
|
@ -958,7 +958,7 @@ export const ALL_CLAIMS_DATA: ClaimData[] = [
|
|||
{
|
||||
slug: "leaders-use-ai-daily-scale-3x-faster",
|
||||
title: "Leaders who use AI daily scale it 3x faster than those who delegate",
|
||||
date: "2024-02-13",
|
||||
date: "2025-11-10",
|
||||
featuredClaim: "Leaders using AI daily are 3x more likely to scale it across organizations than those who delegate adoption.",
|
||||
description: "McKinsey research reveals that executives who personally use AI tools are three times more likely to scale AI across their organizations than those who merely sponsor initiatives. The key difference is not budget or technology, but personal engagement and workflow transformation.",
|
||||
keyPoints: [
|
||||
|
|
@ -996,7 +996,7 @@ export const ALL_CLAIMS_DATA: ClaimData[] = [
|
|||
{
|
||||
slug: "team-stopped-questioning-ai",
|
||||
title: "Your Team Stopped Questioning AI Six Weeks Ago",
|
||||
date: "2024-02-13",
|
||||
date: "2025-11-07",
|
||||
featuredClaim: "Microsoft research shows teams using AI for six months exhibit measurable decline in critical evaluation skills.",
|
||||
description: "Microsoft research reveals that teams using AI without critical evaluation experience declining judgment and decision-making skills. The study highlights the importance of using AI as both a \'doer\' for execution and a \'thinker\' for challenging assumptions and improving strategic outcomes.",
|
||||
keyPoints: [
|
||||
|
|
|
|||
Loading…
Reference in New Issue