mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Improve DCL product sorting logic to show active items first
Update DCL product sorting in DatabaseStorage to prioritize active products (status 'valides', not out of stock, not processed) by assigning them a lower CASE value, and then sort by expiryDate. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 1e4433b5-47ab-464c-b663-fea2e53367dd Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: d092b7f6-df07-4bbf-8198-16c2b8bfdfa4 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/1e4433b5-47ab-464c-b663-fea2e53367dd/LXHtbOp
This commit is contained in:
1 parent
9eace1a1af
commit
5f30c68676
1 file changed
+12
-1
+12
-1
@@ -1948,7 +1948,18 @@ export class DatabaseStorage implements IStorage {
|
||||
query = query.where(and(...conditions));
|
||||
}
|
||||
|
||||
const results = await query.orderBy(asc(dlcProducts.expiryDate));
|
||||
// Tri intelligent : produits actifs en premier, puis produits traités/validés en dernier
|
||||
const results = await query.orderBy(
|
||||
// Priorité 1 : Produits actifs d'abord (non validés, non traités, stock disponible)
|
||||
sql`CASE
|
||||
WHEN ${dlcProducts.status} = 'valides' THEN 3
|
||||
WHEN ${dlcProducts.stockEpuise} = true THEN 2
|
||||
WHEN ${dlcProducts.processedUntilExpiry} = true THEN 2
|
||||
ELSE 1
|
||||
END`,
|
||||
// Priorité 2 : Date d'expiration (croissante)
|
||||
asc(dlcProducts.expiryDate)
|
||||
);
|
||||
|
||||
return results.map((row: any) => ({
|
||||
...row.dlcProduct,
|
||||
|
||||
Reference in new issue
Block a user