feat(articles): expose and filter code centrale (artcentrale)

The code centrale is LaFoir'Fouille's 11-digit product identifier
(prefix 1000x). Only products referenced by the central purchasing
office have one: ~355 800 of 427 700 articles.

The column was already synced from SQL Server and returned by the
detail route via `a.*`, but was absent from the list route and could
not be filtered on.

- list route: select artcentrale, add `artcentrale` (partial match)
  and `has_artcentrale=1|0` query params
- filter matches on prefix AND length 11, so malformed values with a
  valid prefix ('10000', '10000192289P') are excluded
- COALESCE in the predicate: without it, NOT (NULL LIKE '1000%') is
  NULL and the 61 442 NULL rows would vanish from has_artcentrale=0
- normalise '' to null in both routes so they agree
- sync: use safeStr so empty values are stored as NULL, not ''

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Opus 4.8 committed 2026-07-09 09:09:25 +02:00
1 parent 62249e6c13
commit f00b9c4b14
3 files changed
+30 -5

No files matched your search

+1 -1
View File
@@ -44,7 +44,7 @@ async function syncArticles(force) {
suividatecreation: r.SUIVIDATECREATION,
suividatemodif: r.SUIVIDATEMODIF,
nom_no_id: r.NOM_NO_ID,
artcentrale: r.ARTCENTRALE ?? null,
artcentrale: safeStr(r.ARTCENTRALE),
}));
const count = await batchUpsert(pg, 'articles', rows, ['no_id'], ARTICLES_COLS);