Commit Graph
63 Commits
Author SHA1 Message Date
MichaelandClaude Fable 5 753b301066 perf: add missing indexes and remove N+1 queries
The app degraded progressively over a year of data growth. Four causes,
all cumulative:

1. No indexes. Apart from primary keys, unique constraints and
   session.expire, no table carried an index. PostgreSQL does not index
   foreign keys automatically, so every filter and join on group_id,
   supplier_id, order_id and the date columns did a sequential scan.
   Worst offender: user_groups.user_id, read by getUserWithGroups() on
   every authenticated request.

2. N+1 in the order and delivery listings. getOrders,
   getOrdersByDateRange, getDeliveries and getDeliveriesByDateRange
   issued one to two queries per row to load relations. Relations are now
   loaded in bulk and grouped in Node: three queries regardless of volume.

3. /api/sync-order-delivery-status reloaded the whole deliveries table on
   every iteration of its loop over orders. It now uses the deliveries
   getOrders() already attaches.

4. clearExpiredCache() was implemented but never called, so
   invoice_verification_cache grew without bound. Now scheduled every 6h.

Also replaces the full-history downloads on the Groups and Suppliers
pages, which fetched every order and delivery with nested relations only
to count rows, with aggregate endpoints that count in the database.

Indexes are created via scripts/auto-migrate-production.sh, the script
that actually runs at deploy time, using CREATE INDEX CONCURRENTLY so no
write lock is taken. Note that server/migrations.ts explicitly ignores
the migrations/ directory and runs only hardcoded migrations; the SQL
file added there is for reference and manual application.

Verified: typecheck baseline 440 errors, 430 after, none new in the
changed code; vite build passes; server boots; functional test confirms
the aggregate endpoints match the source data including the delivered
count.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-14 11:55:49 +02:00
MichaelandClaude Sonnet 4.6 693d9460cb feat(contacts): add company field to free contacts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-15 11:29:56 +02:00
MichaelandClaude Sonnet 4.6 a430aa1910 feat(contacts): allow admin/directeur to edit supplier coordinates from contacts page
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-15 11:27:33 +02:00
MichaelandClaude Sonnet 4.6 b8ecacee3b merge(main): resolve conflicts keeping codefou + email on suppliers
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-15 11:14:35 +02:00
MichaelandClaude Sonnet 4.6 805664dc32 feat(contacts): add contacts page with per-store management and supplier email field
- New contacts table (group_id, name, role, phone, email, notes) per store
- Suppliers table: add email field with form and card display
- Page /contacts: two-column layout (suppliers read-only / free contacts CRUD)
- Permissions: read all roles, create/edit/delete admin + directeur + manager
- Admin can filter contacts by store; other roles see their own stores only
- Migration SQL: 20260515_add_contacts_and_supplier_email.sql

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-15 10:44:39 +02:00
Michael 3cdd76e223 feat: add BAP webhook configuration and testing routes to server API 2026-04-29 12:11:16 +02:00
Michael 79cd5d4f61 feat: implement date normalization utility and add BAP webhook configuration management routes 2026-04-29 12:02:21 +02:00
Michael 0255dc4aba feat: add BAP file upload functionality to sidebar with processing status modal 2026-04-02 14:58:17 +02:00
Michael 71625031df feat: add WebhookBAPConfig page for managing and testing n8n webhook settings 2026-04-02 14:52:51 +02:00
Michael 8aa5dd1c83 feat: add mobile-optimized customer orders page with creation form and article lookup integration 2026-04-02 14:25:08 +02:00
Michael 7e2eed93df feat: add CustomerOrderForm component with automated product lookup and validation 2026-04-02 14:01:31 +02:00
Michael 95a5a2facc feat: add CustomerOrderForm component with automated product lookup and supplier matching 2026-04-02 13:54:29 +02:00
Michael 22897ede48 feat: add CustomerOrderForm component with automated product lookup and supplier matching 2026-04-02 13:37:16 +02:00
Michael cf57cb5b2d feat: add CustomerOrders page with CRUD operations, status management, and client contact tracking 2026-04-02 12:58:56 +02:00
Michael 55191c511b feat: implement BAP webhook configuration management and customer order tracking support 2026-04-02 12:52:20 +02:00
Michael 576db2d7f4 feat: implement customer order form with automated product lookup and mobile-responsive order page 2026-04-02 11:50:46 +02:00
Michael 6df51a3934 feat: add CustomerOrderForm component with automated article lookup and supplier matching 2026-04-02 11:40:50 +02:00
Michael 58dde2f785 feat: implement CustomerOrderForm component with automated product lookup and create mobile-responsive customer orders page 2026-04-02 11:36:02 +02:00
Michael a91027c10b feat: implement DLC tracking page with EAN lookup and CRUD operations for product expiration management 2026-04-02 09:46:59 +02:00
Michael 44950d2239 feat: implement supplier management module with CRUD operations and optimistic updates 2026-04-02 09:38:30 +02:00
Michael 1488accbdb feat: implement mobile-optimized DLC management page with EAN lookup and status-based filtering 2026-04-02 09:28:46 +02:00
Michael 475c52cede feat: implement dashboard page with store-specific stats, announcement modals, and DLC alerts 2026-04-02 09:25:09 +02:00
Michael b090c8f36a feat: implement DLC management page with EAN lookup, filtering, and CRUD operations 2026-04-02 09:20:54 +02:00
Michael fcf8518684 feat: implement RouterProduction component to handle environment-aware desktop and mobile routing 2026-04-02 09:00:00 +02:00
Michael 4318bb3b5c feat: implement production router with mobile/desktop support and add sidebar navigation component 2026-04-02 08:54:39 +02:00
Michael 40cf456a64 fix(backup): resolve real admin user ID instead of hardcoded 'system' for automatic backups
Fixes FK violation: database_backups.created_by -> users.id
The 'system' user does not exist in the users table, causing
INSERT failures every hour for scheduled backups.
2026-02-10 09:41:12 +01:00
Michael cb1a1a933c fix(dlc): filter stockEpuise products from DLC stats and invalidate stats cache 2026-02-10 09:37:02 +01:00
Michael 16ef17957d fix(db): increase connection pool size and timeout to handle concurrent verifications 2026-01-13 16:54:26 +01:00
Michael 03cb562866 fix(server): resolve duplicate fetch declaration in invoice proxy 2026-01-13 16:44:46 +01:00
Michael 443093573a chore(server): add logging for webhook url in invoice proxy 2026-01-13 16:41:47 +01:00
Michael 65eb74a96e fix(server): use createRequire for form-data to resolve dynamic import issues 2026-01-13 16:36:46 +01:00
Michael 9c0ba9559d fix(server): fix form-data dynamic import for webhook invoice sending 2026-01-13 16:27:35 +01:00
Michael f39b8240e7 chore(deps): npm audit fix - reduce vulnerabilities 2026-01-12 14:36:25 +01:00
Michael 0f8920f326 feat(security): ameliorations securite - CSRF, sanitization validator.js, eval removal 2026-01-12 14:29:02 +01:00
Michael 78adc2c5ae feat(BAP): remplacer destinataire Celia par Jeremy 2026-01-12 14:13:21 +01:00
Michael 8772e7e0b2 feat(BAP): remplacer destinataire Celia par Jeremy 2026-01-12 14:09:25 +01:00
Michael 78b53f576b feat: Implement new dashboard, publicity management, and calendar pages with corresponding server routes. 2026-01-06 11:39:28 +01:00
Michael eb3fb119ee feat: add Publicities page with comprehensive management functionalities including list/calendar views and CRUD operations. 2026-01-05 17:10:10 +01:00
Michael 18c51959af publicité 2026-01-05 13:50:50 +01:00
Michael 5ab5b32ca5 feat: add mobile customer orders page with creation and management functionality 2025-12-10 16:55:03 +01:00
Michael e626659915 feat: implement mobile credit notes management page with CRUD operations and filtering. 2025-12-10 16:48:21 +01:00
Michael 77bbeed9c0 feat: add mobile page for managing credit notes (Avoirs) with search, filter, and CRUD functionalities 2025-12-10 16:31:58 +01:00
Michael 4a25c2040b feat: add mobile customer orders page with order creation and status update functionality 2025-12-10 16:12:57 +01:00
Michael 676d8cee96 feat: add mobile pages for SAV, customer orders, credit notes, and DLC, along with a production router. 2025-12-10 16:04:01 +01:00
Michael 75be8e75b3 feat: add mobile pages for customer orders, publicities, and calendar, and introduce a production router component. 2025-12-10 15:41:47 +01:00
Michael a7c3b2913e feat: add mobile calendar page to display orders and deliveries 2025-12-10 15:11:43 +01:00
Michael 6f94d96420 feat: Implement a mobile calendar page to display orders and deliveries as events. 2025-12-10 14:58:19 +01:00
Michael d64ed9bbcd feat: add mobile calendar page to display orders and deliveries 2025-12-10 14:51:22 +01:00
Michael 8212bf002d feat: add mobile calendar page to display orders and deliveries as events. 2025-12-10 14:44:54 +01:00
Michael 6378fa5a7c feat: add mobile calendar page to display orders and deliveries as events. 2025-12-10 14:24:18 +01:00
Michael 7043884e68 feat: add mobile pages for delivery and order listing with search and filter capabilities. 2025-12-10 14:17:32 +01:00
Michael 29520c4264 feat: add base mobile layout component with header, bottom navigation, and side menu. 2025-12-10 14:06:45 +01:00
Michael 7c7a4478c3 feat: add MobileApp wrapper with StoreProvider and integrate mobile-specific routing for mobile pages. 2025-12-10 14:02:37 +01:00
Michael 7f4c172eeb feat: implement dedicated mobile layout with bottom navigation and store selection. 2025-12-10 13:56:42 +01:00
Michael 583a2469c9 feat: introduce RouterProduction component for authenticated and responsive application routing. 2025-12-10 13:50:01 +01:00
Michael 946b5f30bd feat: add mobile layout and bottom navigation components 2025-12-10 13:42:05 +01:00
Michael 69773e3d2f feat: add mobile tasks page with creation/edit form and new layout component 2025-12-10 13:25:24 +01:00
Michael dd682024fd feat: implement mobile task management page for mobile devices, including task creation, editing, and listing. 2025-12-10 13:16:45 +01:00
Michael 3a8183f6a5 feat: Add mobile tasks page with task creation, editing, and listing functionalities. 2025-12-10 13:09:24 +01:00
Michael 5894b486b7 feat: implement mobile task management page with create and edit task form 2025-12-10 13:03:30 +01:00
Michael b51687f301 feat: introduce responsive task management with a dedicated mobile tasks page and form 2025-12-10 12:51:58 +01:00
Michael 1df477927a feat: Add publicities management page with year/month filtering, list/calendar views, and CRUD functionality. 2025-12-10 12:06:14 +01:00
Michael 6b719fb111 feat: implement Sidebar component including navigation, user details, logout, and BAP document upload with webhook integration. 2025-12-08 09:12:45 +01:00