mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-21 22:18:17 +02:00
Add debugging tools to help diagnose order display issues
Introduce new API endpoints and enhanced logging in `routes.ts` and `storage.ts` to allow for granular inspection of customer order data and filtering logic, aiding in the diagnosis of production discrepancies. Replit-Commit-Author: Agent Replit-Commit-Session-Id: a3de0820-9397-41b2-b000-7931ee9c29de Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/a3de0820-9397-41b2-b000-7931ee9c29de/mKF47ul
This commit is contained in:
1 parent
f21d807968
commit
7613b257cc
2 files changed
+121
-9
No files matched your search
+28
-7
@@ -1324,6 +1324,8 @@ export class DatabaseStorage implements IStorage {
|
||||
|
||||
// Real implementations for production operations
|
||||
async getCustomerOrders(groupIds?: number[]): Promise<CustomerOrderWithRelations[]> {
|
||||
console.log('🔍 [PRODUCTION DEBUG] getCustomerOrders called with groupIds:', groupIds);
|
||||
|
||||
let query = db
|
||||
.select({
|
||||
customerOrder: customerOrders,
|
||||
@@ -1336,15 +1338,34 @@ export class DatabaseStorage implements IStorage {
|
||||
|
||||
if (groupIds && groupIds.length > 0) {
|
||||
query = query.where(inArray(customerOrders.groupId, groupIds));
|
||||
console.log('🔍 [PRODUCTION DEBUG] Filtering by groupIds:', groupIds);
|
||||
}
|
||||
|
||||
const results = await query.orderBy(desc(customerOrders.createdAt));
|
||||
return results.map((row: any) => ({
|
||||
...row.customerOrder,
|
||||
supplier: row.supplier,
|
||||
group: row.group,
|
||||
creator: row.creator || { id: row.customerOrder.createdBy, username: 'unknown' }
|
||||
}));
|
||||
try {
|
||||
const results = await query.orderBy(desc(customerOrders.createdAt));
|
||||
console.log('🔍 [PRODUCTION DEBUG] Raw SQL results count:', results.length);
|
||||
|
||||
// Debug: Log some sample data
|
||||
if (results.length > 0) {
|
||||
console.log('🔍 [PRODUCTION DEBUG] Sample results (first 3):');
|
||||
results.slice(0, 3).forEach((row, idx) => {
|
||||
console.log(` [${idx}] Order ID: ${row.customerOrder?.id}, GroupId: ${row.customerOrder?.groupId}, Customer: ${row.customerOrder?.customerName}, Created: ${row.customerOrder?.createdAt}`);
|
||||
});
|
||||
}
|
||||
|
||||
const mappedResults = results.map((row: any) => ({
|
||||
...row.customerOrder,
|
||||
supplier: row.supplier,
|
||||
group: row.group,
|
||||
creator: row.creator || { id: row.customerOrder.createdBy, username: 'unknown' }
|
||||
}));
|
||||
|
||||
console.log('🔍 [PRODUCTION DEBUG] Final mapped results count:', mappedResults.length);
|
||||
return mappedResults;
|
||||
} catch (error) {
|
||||
console.error('❌ [PRODUCTION ERROR] getCustomerOrders failed:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async getCustomerOrder(id: number): Promise<CustomerOrderWithRelations | undefined> {
|
||||
|
||||
Reference in new issue
Block a user