gitea
This commit is contained in:
32
backend/scripts/debug-fetch.ts
Normal file
32
backend/scripts/debug-fetch.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import 'dotenv/config';
|
||||
import { query } from '../src/db';
|
||||
import { fetchPage } from '../src/services/fetcher';
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
const result = await query('SELECT * FROM monitors WHERE url LIKE $1', ['%3002%']);
|
||||
const testMonitor = result.rows[0];
|
||||
|
||||
if (testMonitor) {
|
||||
console.log(`Found monitor: "${testMonitor.name}"`);
|
||||
console.log(`URL in DB: "${testMonitor.url}"`);
|
||||
console.log(`URL length: ${testMonitor.url.length}`);
|
||||
|
||||
console.log('Testing fetchPage for DB URL...');
|
||||
const result = await fetchPage(testMonitor.url);
|
||||
console.log('Result:', {
|
||||
status: result.status,
|
||||
byteLength: result.html.length,
|
||||
error: result.error
|
||||
});
|
||||
} else {
|
||||
console.log('No monitor found with port 3002');
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error:', err);
|
||||
} finally {
|
||||
process.exit();
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
48
backend/scripts/debug-importance.ts
Normal file
48
backend/scripts/debug-importance.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
import { calculateImportanceScore } from '../src/services/importance';
|
||||
|
||||
async function run() {
|
||||
console.log('Testing Importance Score Calculation');
|
||||
|
||||
const testCases = [
|
||||
{
|
||||
name: 'Case 1: 100% change, short content, main content',
|
||||
factors: {
|
||||
changePercentage: 100,
|
||||
keywordMatches: 0,
|
||||
isMainContent: true,
|
||||
isRecurringPattern: false,
|
||||
contentLength: 200
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'Case 2: 100% change, short content, NOT main content',
|
||||
factors: {
|
||||
changePercentage: 100,
|
||||
keywordMatches: 0,
|
||||
isMainContent: false,
|
||||
isRecurringPattern: false,
|
||||
contentLength: 200
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'Case 3: 0.1% change, short content',
|
||||
factors: {
|
||||
changePercentage: 0.1,
|
||||
keywordMatches: 0,
|
||||
isMainContent: true,
|
||||
isRecurringPattern: false,
|
||||
contentLength: 50
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
for (const test of testCases) {
|
||||
const score = calculateImportanceScore(test.factors);
|
||||
console.log(`\n${test.name}:`);
|
||||
console.log(`Factors:`, test.factors);
|
||||
console.log(`Score: ${score}`);
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
19
backend/scripts/migration_add_importance_score.ts
Normal file
19
backend/scripts/migration_add_importance_score.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
import 'dotenv/config';
|
||||
import { query } from '../src/db';
|
||||
|
||||
async function run() {
|
||||
console.log('Migrating database: Adding importance_score to snapshots table...');
|
||||
try {
|
||||
await query(`
|
||||
ALTER TABLE snapshots
|
||||
ADD COLUMN IF NOT EXISTS importance_score INTEGER DEFAULT 0;
|
||||
`);
|
||||
console.log('Migration successful: importance_score column added.');
|
||||
} catch (err) {
|
||||
console.error('Migration failed:', err);
|
||||
}
|
||||
process.exit();
|
||||
}
|
||||
|
||||
run();
|
||||
Reference in New Issue
Block a user