Major restructure: Remove Confluence, add V2 data structure, organize for dev/prod
- Import real data from PDF (35 Bambu Lab filaments) - Remove all Confluence integration and dependencies - Implement new V2 data structure with proper inventory tracking - Add backwards compatibility for existing data - Create enhanced UI components (ColorSwatch, InventoryBadge, MaterialBadge) - Add advanced filtering with quick filters and multi-criteria search - Organize codebase for dev/prod environments - Update Lambda functions to support both V1/V2 formats - Add inventory summary dashboard - Clean up project structure and documentation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
68
scripts/data-import/clear-dynamo.js
Executable file
68
scripts/data-import/clear-dynamo.js
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
require('dotenv').config({ path: '.env.local' });
|
||||
const AWS = require('aws-sdk');
|
||||
|
||||
// Configure AWS
|
||||
AWS.config.update({
|
||||
region: process.env.AWS_REGION || 'eu-central-1'
|
||||
});
|
||||
|
||||
const dynamodb = new AWS.DynamoDB.DocumentClient();
|
||||
const TABLE_NAME = process.env.DYNAMODB_TABLE_NAME || 'filamenteka-filaments';
|
||||
|
||||
async function clearTable() {
|
||||
console.log(`Clearing all items from ${TABLE_NAME}...`);
|
||||
|
||||
try {
|
||||
// First, scan to get all items
|
||||
const scanParams = {
|
||||
TableName: TABLE_NAME,
|
||||
ProjectionExpression: 'id'
|
||||
};
|
||||
|
||||
const items = [];
|
||||
let lastEvaluatedKey = null;
|
||||
|
||||
do {
|
||||
if (lastEvaluatedKey) {
|
||||
scanParams.ExclusiveStartKey = lastEvaluatedKey;
|
||||
}
|
||||
|
||||
const result = await dynamodb.scan(scanParams).promise();
|
||||
items.push(...result.Items);
|
||||
lastEvaluatedKey = result.LastEvaluatedKey;
|
||||
} while (lastEvaluatedKey);
|
||||
|
||||
console.log(`Found ${items.length} items to delete`);
|
||||
|
||||
// Delete in batches of 25
|
||||
const chunks = [];
|
||||
for (let i = 0; i < items.length; i += 25) {
|
||||
chunks.push(items.slice(i, i + 25));
|
||||
}
|
||||
|
||||
for (const chunk of chunks) {
|
||||
const params = {
|
||||
RequestItems: {
|
||||
[TABLE_NAME]: chunk.map(item => ({
|
||||
DeleteRequest: { Key: { id: item.id } }
|
||||
}))
|
||||
}
|
||||
};
|
||||
|
||||
await dynamodb.batchWrite(params).promise();
|
||||
console.log(`Deleted ${chunk.length} items`);
|
||||
}
|
||||
|
||||
console.log('Table cleared successfully!');
|
||||
} catch (error) {
|
||||
console.error('Error clearing table:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Run if called directly
|
||||
if (require.main === module) {
|
||||
clearTable();
|
||||
}
|
||||
Reference in New Issue
Block a user