MSIN-4574 — Increment version code to 4.73.003 and enhance the ChronoTrack API by implementing logic to omit Canadian provinces when the associated country is not Canada, logging the reason for omission. Improved feedback messages in the API to clarify the handling of location data and ensure accurate synchronization. Documentation updated to reflect these changes and enhance user understanding of the new location handling rules.

This commit is contained in:
2026-08-11 18:50:59 -04:00
parent 97affc5080
commit c7527bdb03
6 changed files with 79 additions and 11 deletions

View File

@ -43,7 +43,9 @@ La **liste** meta renvoie plutôt :
`fx_chronotrack_verify.php` mappe ces alias — sinon faux écarts « CT ∅ ».
**Écriture pays/région** : seulement `location_country` / `location_region` / `country_name`
(pas `country_code` / `state_code` — collision possible → QC dans le pays).
(pas `country_code` / `state_code` — collision possible → QC dans le pays).
Si province **canadienne** (ex. `QC`) et pays MS1 ≠ `CA`**province non envoyée** + log `skip_region`
(pas de réparation auto du pays ; pas de faux écart à la vérif).
**Push** (règle produit MSIN-4574 — **correctitude > vitesse**) :
- entry déjà dans CT (`entry_id`) → **PUT** unitaire (écrase pays / région / bib)

View File

@ -2022,7 +2022,9 @@ function fxChronotrackApiAdminRenderPageScript($intEveId, $arrConfig, $blnClosed
+ '<code>envoi_bib=</code> valeur envoyée, '
+ '<code>conflit_bib</code> = dossard différé (2e passe / swap via PUT clear), '
+ '<code>RETRY_BIB</code> = 2e tentative. '
+ 'Si la 2e passe échoue → erreur visible.</p>';
+ 'Si la 2e passe échoue → erreur visible. '
+ '<br><code>skip_region</code> = province MS1 non envoyée (ex. QC + pays France) '
+ '— saisie incohérente, pas un bug denvoi.</p>';
html += '<div class="ct-api-logs-scroll border rounded">';
html += '<table class="table table-sm table-striped mb-0" style="font-size:0.78rem;">';
html += '<thead class="thead-light"><tr><th>Quand</th><th>Action</th><th>Statut</th><th>par_id</th><th>Message</th></tr></thead><tbody>';

View File

@ -306,6 +306,42 @@ function fxChronotrackApiSyncIso2ToIso3($strIso2) {
return isset($tabMap[$strIso2]) ? $tabMap[$strIso2] : '';
}
/**
* MSIN-4574 — codes province Canada (pro_iso typique).
*/
function fxChronotrackApiSyncIsCanadianProvinceCode($strCode) {
static $tab = array(
'AB' => 1, 'BC' => 1, 'MB' => 1, 'NB' => 1, 'NL' => 1, 'NS' => 1,
'NT' => 1, 'NU' => 1, 'ON' => 1, 'PE' => 1, 'QC' => 1, 'SK' => 1, 'YT' => 1,
);
$strCode = strtoupper(trim((string)$strCode));
return $strCode !== '' && isset($tab[$strCode]);
}
/**
* MSIN-4574 — si province CA alors que pays ≠ CA (ex. Kathy : QC + France),
* on nenvoie pas la province (CT refuse) — sans corriger le pays MS1.
*
* @return string raison (vide = OK à envoyer)
*/
function fxChronotrackApiSyncLocationRegionOmitReason($strState, $strCountryIso2) {
$strState = strtoupper(trim((string)$strState));
$strCountryIso2 = strtoupper(trim((string)$strCountryIso2));
if ($strState === '') {
return '';
}
// Pas de pays MS1 → on envoie quand même la province (meilleur effort)
if ($strCountryIso2 === '') {
return '';
}
if (fxChronotrackApiSyncIsCanadianProvinceCode($strState) && $strCountryIso2 !== 'CA') {
return 'Province ' . $strState . ' non envoyée — pays MS1=' . $strCountryIso2
. ' (incohérent : CT naccepte pas une province canadienne hors Canada.'
. ' Corriger le pays en MS1 si besoin).';
}
return '';
}
/**
* MSIN-4574 — ISO-2 pays (pay_iso BD).
* Preuve calibrage 2026-08-11 : CT Athlete Info / export stockent location_country + COUNTRY_CODE = « CA » (pas CAN).
@ -912,18 +948,25 @@ function fxChronotrackApiSyncBuildEntryPayload(array $arrRow, array $arrRaceMap,
}
if ($strState !== '') {
// MSIN-4574 — nenvoyer QUE location_region (pas state_code) :
// state_code en upsert bulk a pu finir dans location_country côté CT (QC dans le pays).
$arrEntry['location_region'] = $strState;
// MSIN-4574 — ne pas envoyer une province CA/US si le pays MS1 ne match pas
// (ex. QC + France → CT refuse ; pas de « réparation » auto du pays).
$strOmitRegion = fxChronotrackApiSyncLocationRegionOmitReason($strState, $strCountry);
if ($strOmitRegion === '') {
// Nenvoyer QUE location_region (pas state_code) :
// state_code en upsert bulk a pu finir dans location_country côté CT (QC dans le pays).
$arrEntry['location_region'] = $strState;
} else {
// Marqueur interne → log push_prepare, retiré avant HTTP / vérif
$arrEntry['_skip_region_log'] = $strOmitRegion;
}
}
// MSIN-4574 — pays / province (calibrage sonde lecture + export confirmed entries 2026-08-11) :
// location_country = ISO-2 (CA), location_region = pro_iso (QC), country_name = libellé.
// Pas de country_code en écriture entry (même risque de collision que state_code).
$strIso2 = fxChronotrackApiSyncResolveCountryIso2($arrRow);
$strCountryName = fxChronotrackApiSyncResolveCountryLabel($arrRow);
if ($strIso2 !== '') {
$arrEntry['location_country'] = $strIso2;
if ($strCountry !== '') {
$arrEntry['location_country'] = $strCountry;
}
if ($strCountryName !== '') {
$arrEntry['country_name'] = $strCountryName;
@ -956,13 +999,13 @@ function fxChronotrackApiSyncBuildEntryPayload(array $arrRow, array $arrRaceMap,
function fxChronotrackApiSyncPayloadForPost(array $arrPayload) {
$arrOut = $arrPayload;
unset($arrOut['entry_id']);
unset($arrOut['entry_id'], $arrOut['_skip_region_log']);
return $arrOut;
}
function fxChronotrackApiSyncPayloadForPut(array $arrPayload) {
$arrOut = $arrPayload;
unset($arrOut['entry_id']);
unset($arrOut['entry_id'], $arrOut['_skip_region_log']);
return $arrOut;
}

View File

@ -1047,6 +1047,25 @@ function fxChronotrackApiSyncPushPrepare($intEveId, $arrOptions = array()) {
$arrPayload['entry_id'] = $strCtEntryId;
$intWithEntryId++;
}
// MSIN-4574 — province omise (pays incohérent) → log support, pas de faux écart
if (!empty($arrPayload['_skip_region_log'])) {
$strSkipMsg = trim((string)$arrPayload['_skip_region_log']);
$strSkipName = trim(
trim((string)($arrPayload['first_name'] ?? ''))
. ' '
. trim((string)($arrPayload['last_name'] ?? ''))
);
fxChronotrackApiSyncLog(
$intEveId,
intval($arrItem['row']['par_id'] ?? 0),
'skip_region',
'ok',
($strSkipName !== '' ? ($strSkipName . ' — ') : '')
. 'ext ' . ($arrPayload['external_id'] ?? '')
. ' — ' . $strSkipMsg
);
unset($arrPayload['_skip_region_log']);
}
$tabBatch[] = $arrPayload;
$strBibMs1 = fxChronotrackApiSyncExtractBib($arrItem['row'] ?? array());
$strBibSent = isset($arrPayload['bib']) ? trim((string)$arrPayload['bib']) : '';

View File

@ -20,6 +20,8 @@ function fxChronotrackApiSyncVerifySkipPayloadKeys() {
'status' => true,
'country_code' => true,
'state_code' => true,
// Marqueur interne omit province (jamais comparé / envoyé)
'_skip_region_log' => true,
);
}

View File

@ -7,7 +7,7 @@
* Constantes *
*
**************/
define('_VERSION_CODE', '4.73.002'); // MSIN-4574 — correctitude: PUT si entry_id (plus POST bulk update)
define('_VERSION_CODE', '4.73.003'); // MSIN-4574 — omit province CA si pays≠CA + log skip_region
define('_DATE_CODE', '2026-08-11');
//MSIN-4290
define('QR_SECRET_KEY', 'ms1_qr_2026_cle_secrete_longue_et_fixe');