#!/usr/bin/env node
/**
* Simple check for why tasks aren't showing
*/
import pkg from 'pg';
const { Client } = pkg;
const client = new Client({
host: 'localhost',
port: 5433,
database: 'pg-litefarm',
user: 'postgres',
password: 'postgres',
});
const userId = '3f930e96-4782-4e53-ac9a-3e855f2e7a54';
console.log('Checking why tasks are not showing in webapp...\n');
await client.connect();
// Get all tasks with their full details
const result = await client.query(
`SELECT
t.task_id,
t.task_type_id,
tt.task_name,
tt.task_translation_key,
tt.deleted as type_deleted,
t.due_date,
t.complete_date,
t.abandon_date,
t.deleted as task_deleted
FROM task t
LEFT JOIN task_type tt ON t.task_type_id = tt.task_type_id
WHERE t.owner_user_id = $1
ORDER BY t.created_at DESC
LIMIT 10`,
[userId]
);
console.log(`Found ${result.rows.length} tasks:\n`);
result.rows.forEach((t, idx) => {
const status = t.complete_date ? 'โ
COMPLETE' : t.abandon_date ? 'โ ABANDONED' : t.task_deleted ? '๐๏ธ DELETED' : '๐ ACTIVE';
const typeStatus = t.task_name ? `${t.task_name} (${t.task_translation_key})` : 'โ MISSING TASK TYPE!';
const typeDeleted = t.type_deleted ? ' [TYPE DELETED]' : '';
console.log(`${idx + 1}. Task ID: ${String(t.task_id).substring(0, 12)}...`);
console.log(` Status: ${status}`);
console.log(` Type: ${typeStatus}${typeDeleted}`);
console.log(` Due: ${t.due_date?.toISOString().split('T')[0] || 'N/A'}`);
console.log('');
});
await client.end();
console.log('\nDIAGNOSIS:');
console.log('If "MISSING TASK TYPE" appears above, that task will not show in the webapp!');
console.log('If "[TYPE DELETED]" appears, that task will not show in the webapp!');
console.log('Tasks that are COMPLETE, ABANDONED, or DELETED may not show depending on filters.');