📋 What Was Accomplished Backend Changes: - ✅ Enhanced API Endpoint: Updated GET /api/v1/events to accept optional date query parameter - ✅ Input Validation: Added YYYY-MM-DD format validation to PaginationQueryDto - ✅ Database Filtering: Implemented timezone-aware date filtering in EventsService - ✅ Controller Integration: Updated EventsController to pass date parameter to service Frontend Changes: - ✅ Date Picker Component: Created reusable DatePicker component following project design system - ✅ Gallery UI Enhancement: Integrated date picker into gallery page with clear labeling - ✅ State Management: Implemented reactive date state with automatic re-fetching - ✅ Clear Filter Functionality: Added "Clear Filter" button for easy reset - ✅ Enhanced UX: Improved empty states for filtered vs unfiltered views 🔍 Technical Implementation API Design: GET /api/v1/events?date=2025-08-02&limit=20&cursor=xxx Key Files Modified: - meteor-web-backend/src/events/dto/pagination-query.dto.ts - meteor-web-backend/src/events/events.service.ts - meteor-web-backend/src/events/events.controller.ts - meteor-frontend/src/components/ui/date-picker.tsx (new) - meteor-frontend/src/app/gallery/page.tsx - meteor-frontend/src/hooks/use-events.ts - meteor-frontend/src/services/events.ts ✅ All Acceptance Criteria Met 1. ✅ Backend API Enhancement: Accepts optional date parameter 2. ✅ Date Filtering Logic: Returns events for specific calendar date 3. ✅ Date Picker UI: Clean, accessible interface component 4. ✅ Automatic Re-fetching: Immediate data updates on date selection 5. ✅ Filtered Display: Correctly shows only events for selected date 6. ✅ Clear Filter: One-click reset to view all events 🧪 Quality Assurance - ✅ Backend Build: Successful compilation with no errors - ✅ Frontend Build: Successful Next.js build with no warnings - ✅ Linting: All ESLint checks pass - ✅ Functionality: Feature working as specified 🎉 Epic 2 Complete! With Story 2.9 completion, Epic 2: Commercialization & Core User Experience is now DONE! Epic 2 Achievements: - 🔐 Full-stack device status monitoring - 💳 Robust payment and subscription system - 🛡️ Subscription-based access control - 📊 Enhanced data browsing with detail pages - 📅 Date-based event filtering
70 lines
2.3 KiB
JavaScript
70 lines
2.3 KiB
JavaScript
const { Client } = require('pg');
|
|
require('dotenv').config();
|
|
|
|
async function testDatabaseConnection() {
|
|
console.log('=== Database Connection Test ===');
|
|
console.log('DATABASE_URL from .env:', process.env.DATABASE_URL);
|
|
|
|
if (!process.env.DATABASE_URL) {
|
|
console.error('❌ DATABASE_URL not found in environment variables');
|
|
console.log('Current environment variables:');
|
|
Object.keys(process.env).filter(key => key.includes('DATABASE')).forEach(key => {
|
|
console.log(`${key}: ${process.env[key]}`);
|
|
});
|
|
return;
|
|
}
|
|
|
|
const client = new Client({
|
|
connectionString: process.env.DATABASE_URL,
|
|
ssl: false, // Set to true if your database requires SSL
|
|
});
|
|
|
|
try {
|
|
console.log('🔄 Attempting to connect to database...');
|
|
await client.connect();
|
|
console.log('✅ Successfully connected to database!');
|
|
|
|
// Test a simple query
|
|
const result = await client.query('SELECT version()');
|
|
console.log('📊 Database version:', result.rows[0].version);
|
|
|
|
// Check if our tables exist
|
|
const tablesResult = await client.query(`
|
|
SELECT table_name
|
|
FROM information_schema.tables
|
|
WHERE table_schema = 'public'
|
|
AND table_name IN ('user_profiles', 'user_identities')
|
|
`);
|
|
|
|
console.log('📋 Found tables:', tablesResult.rows.map(row => row.table_name));
|
|
|
|
if (tablesResult.rows.length === 0) {
|
|
console.log('⚠️ No user tables found. You may need to run migrations.');
|
|
console.log('Run: npm run migrate:up');
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('❌ Database connection failed:', error.message);
|
|
console.error('🔍 Error details:', {
|
|
code: error.code,
|
|
errno: error.errno,
|
|
syscall: error.syscall,
|
|
address: error.address,
|
|
port: error.port
|
|
});
|
|
|
|
if (error.code === 'ENOTFOUND') {
|
|
console.error('🌐 DNS resolution failed - check if the host is correct');
|
|
} else if (error.code === 'ECONNREFUSED') {
|
|
console.error('🚫 Connection refused - check if database server is running');
|
|
} else if (error.code === '28P01') {
|
|
console.error('🔐 Authentication failed - check username/password');
|
|
} else if (error.code === '3D000') {
|
|
console.error('🗄️ Database does not exist - check database name');
|
|
}
|
|
} finally {
|
|
await client.end();
|
|
}
|
|
}
|
|
|
|
testDatabaseConnection(); |