Changeset 46
- Timestamp:
- Sep 12, 2022, 7:34:40 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/index.php
r45 r46 17 17 function Run() 18 18 { 19 20 19 } 21 20 } … … 36 35 function __construct() 37 36 { 38 $this->LeaderboardURL = 'https://registrace.teribear.cz/Leaderboard'; 37 //$this->LeaderboardURL = 'https://registrace.teribear.cz/Leaderboard'; 38 $this->LeaderboardURL = 'https://leaderboard.teribear.cz/'; 39 39 $this->BaseURL = ''; 40 40 $this->LinkLocaleExceptions = array(); … … 173 173 foreach ($JSON['items'] as $Item) 174 174 { 175 // Use RegistrationNumber as ChipNumber. 176 $Item['ChipNumber'] = $Item['RegistrationNumber'] * 1; 177 unset($Item['RegistrationNumber']); 178 if ($Item['Name'] != null) 179 { 180 // Normalize names 181 $Item['Name'] = trim($Item['Name']); 182 while (strpos($Item['Name'], ' ') !== false) 183 { 184 $Item['Name'] = str_replace(' ', ' ', $Item['Name']); 185 } 186 } 175 187 $Result[] = $Item; 176 188 } … … 186 198 { 187 199 $Output = ''; 188 /*200 189 201 $this->Database->query('DELETE FROM RunnerStat'); 190 202 $this->Database->query('DELETE FROM Runner'); … … 192 204 $this->Database->query('DELETE FROM Team'); 193 205 $this->Database->query('DELETE FROM Import'); 194 */ 195 206 196 207 // Find duplicates 197 208 /* … … 337 348 $Runners[$Item['ChipNumber']] = array('Id' => $RunnerId, 'Distance' => -1, 'Team' => $TeamId); 338 349 $NextRunnerId++; 339 } else { 350 } else 351 { 340 352 $RunnerId = $Runners[$Item['ChipNumber']]['Id']; 341 353 … … 347 359 } else 348 360 { 349 $NewRunnerTeamId = $Teams[$Item['TeamId']]['Id']; 361 if (!array_key_exists($Item['TeamId'], $Teams)) 362 { 363 $NewRunnerTeamId = $NextTeamId; 364 $Queries[] = $this->Database->GetInsert('Team', array( 365 'Id' => $NewRunnerTeamId, 366 'Name' => '', 367 'WebId' => $Item['TeamId'], 368 'Year' => $Year, 369 'IsFamily' => 0, 370 )); 371 $Teams[$Item['TeamId']] = array('Id' => $NewRunnerTeamId, 'Distance' => -1); 372 $NextTeamId++; 373 } else 374 { 375 $NewRunnerTeamId = $Teams[$Item['TeamId']]['Id']; 376 } 350 377 } 351 378 if ($OldRunnerTeamId != $NewRunnerTeamId) … … 369 396 if (($Item['Type'] == 'team') or ($Item['Type'] == 'rodina')) 370 397 { 398 if ($Item['Name'] == null) $Item['Name'] = ''; 371 399 if ($Item['Type'] == 'rodina') $IsFamily = 1; 372 400 else $IsFamily = 0; … … 446 474 'Hash' => $Hash, 447 475 'ItemCount' => count($Items) 448 )); 449 //file_put_contents('import/'.$Hash.'.txt', print_r($Items, true)); 476 )); 450 477 } 451 478 $Output .= T('Data synchronization from leaderboard finished.<br/>');
Note:
See TracChangeset
for help on using the changeset viewer.