mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Improve how advertisements are displayed by fixing sorting
Adjust the advertisement retrieval to use direct column ordering instead of SQL CAST for better production compatibility and logging. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 0ec86cdf-a5be-4b0e-84a3-07b926f5cc80 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/0ec86cdf-a5be-4b0e-84a3-07b926f5cc80/0gylnen
This commit is contained in:
1 parent
6cf7631bdf
commit
1aa3069d89
2 files changed
+14
-7
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 230 KiB |
+14
-7
@@ -1209,13 +1209,13 @@ export class DatabaseStorage implements IStorage {
|
||||
query = query.where(eq(publicities.year, year));
|
||||
}
|
||||
|
||||
const results = await query.orderBy(sql`CAST(${publicities.pubNumber} AS INTEGER) ASC`);
|
||||
// SAFE: Use simple column ordering instead of SQL CAST which fails in production
|
||||
const results = await query.orderBy(publicities.pubNumber);
|
||||
|
||||
// LOG: Debug du tri des publicités avec détails complets
|
||||
console.log(`📋 PUBLICITES: Tri par pubNumber croissant (CAST AS INTEGER) - ${results.length} résultats:`);
|
||||
console.log('🔍 PREMIERS RESULTATS:', results.slice(0, 5).map((p, i) => `${i+1}. N°${p.pubNumber} - ${p.designation}`));
|
||||
if (results.length > 5) {
|
||||
console.log('🔍 DERNIERS RESULTATS:', results.slice(-2).map((p, i) => `${results.length-1+i}. N°${p.pubNumber} - ${p.designation}`));
|
||||
// LOG: Debug des publicités récupérées
|
||||
console.log(`📋 PUBLICITES FETCHED: ${results.length} résultats pour année ${year || 'toutes'}`);
|
||||
if (results.length > 0) {
|
||||
console.log('🔍 PREMIERS RESULTATS:', results.slice(0, 3).map((p, i) => `${i+1}. N°${p.pubNumber} - ${p.designation}`));
|
||||
}
|
||||
|
||||
const publicityIds = results.map((p: any) => p.id);
|
||||
@@ -1231,7 +1231,14 @@ export class DatabaseStorage implements IStorage {
|
||||
.where(inArray(publicityParticipations.publicityId, publicityIds))
|
||||
: [];
|
||||
|
||||
return results.map((publicity: any) => ({
|
||||
// Sort by pubNumber as integer on the server side for consistency
|
||||
const sortedResults = results.sort((a, b) => {
|
||||
const numA = parseInt(a.pubNumber) || 0;
|
||||
const numB = parseInt(b.pubNumber) || 0;
|
||||
return numA - numB;
|
||||
});
|
||||
|
||||
return sortedResults.map((publicity: any) => ({
|
||||
...publicity,
|
||||
participations: participations
|
||||
.filter((p: any) => p.publicityId === publicity.id)
|
||||
|
||||
Reference in new issue
Block a user