- Create Economist SubmissionTracking package correctly: * mainArticle = full blog post content * coverLetter = 216-word SIR— letter * Links to blog post via blogPostId - Archive 'Letter to The Economist' from blog posts (it's the cover letter) - Fix date display on article cards (use published_at) - Target publication already displaying via blue badge Database changes: - Make blogPostId optional in SubmissionTracking model - Economist package ID: 68fa85ae49d4900e7f2ecd83 - Le Monde package ID: 68fa2abd2e6acd5691932150 Next: Enhanced modal with tabs, validation, export 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
101 lines
3.1 KiB
JavaScript
101 lines
3.1 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
const { MongoClient, ObjectId } = require('mongodb');
|
|
require('dotenv').config();
|
|
|
|
const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017/tractatus_dev';
|
|
|
|
async function fixImportedArticles() {
|
|
const client = new MongoClient(MONGODB_URI);
|
|
|
|
try {
|
|
await client.connect();
|
|
console.log('✅ Connected to MongoDB\n');
|
|
|
|
const db = client.db();
|
|
const blogPosts = db.collection('blog_posts');
|
|
const submissions = db.collection('submission_tracking');
|
|
|
|
// Find the 3 main articles
|
|
const articles = await blogPosts.find({
|
|
slug: { $in: [
|
|
'amoral-intelligence',
|
|
'the-new-a-i-amoral-intelligence',
|
|
'letter-to-the-economist-amoral-intelligence'
|
|
]}
|
|
}).toArray();
|
|
|
|
console.log(`Found ${articles.length} articles to fix\n`);
|
|
|
|
for (const article of articles) {
|
|
console.log(`📄 Processing: ${article.title}`);
|
|
|
|
// 1. Update status to pending_review
|
|
await blogPosts.updateOne(
|
|
{ _id: article._id },
|
|
{ $set: { status: 'pending_review' } }
|
|
);
|
|
console.log(` ✅ Status updated to: pending_review`);
|
|
|
|
// 2. Create submission tracking record
|
|
let publicationId, publicationName, contentType;
|
|
|
|
if (article.slug === 'amoral-intelligence') {
|
|
publicationId = 'nyt-oped';
|
|
publicationName = 'New York Times';
|
|
contentType = 'oped';
|
|
} else if (article.slug === 'the-new-a-i-amoral-intelligence') {
|
|
publicationId = 'economist-article';
|
|
publicationName = 'The Economist';
|
|
contentType = 'essay';
|
|
} else if (article.slug === 'letter-to-the-economist-amoral-intelligence') {
|
|
publicationId = 'economist-letter';
|
|
publicationName = 'The Economist';
|
|
contentType = 'letter';
|
|
}
|
|
|
|
// Check if submission tracking already exists
|
|
const existingSubmission = await submissions.findOne({ blogPostId: article._id });
|
|
|
|
if (!existingSubmission) {
|
|
const submissionRecord = {
|
|
blogPostId: article._id,
|
|
publicationId,
|
|
publicationName,
|
|
title: article.title,
|
|
wordCount: article.content ? article.content.split(/\s+/).length : 0,
|
|
contentType,
|
|
status: 'ready',
|
|
submissionMethod: publicationId === 'nyt-oped' ? 'email' : 'email',
|
|
submissionEmail: publicationId === 'nyt-oped' ? 'oped@nytimes.com' : 'letters@economist.com',
|
|
notes: [{
|
|
content: 'Imported from existing outreach materials',
|
|
author: null,
|
|
createdAt: new Date()
|
|
}],
|
|
createdAt: new Date(),
|
|
updatedAt: new Date()
|
|
};
|
|
|
|
await submissions.insertOne(submissionRecord);
|
|
console.log(` ✅ Submission tracking created for ${publicationName}`);
|
|
} else {
|
|
console.log(` ⏭️ Submission tracking already exists`);
|
|
}
|
|
|
|
console.log('');
|
|
}
|
|
|
|
console.log('✅ All articles fixed!\n');
|
|
|
|
await client.close();
|
|
process.exit(0);
|
|
|
|
} catch (error) {
|
|
console.error('Error:', error);
|
|
await client.close();
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
fixImportedArticles();
|