Changeset 26 for trunk


Ignore:
Timestamp:
Sep 11, 2019, 9:20:29 AM (5 years ago)
Author:
chronos
Message:
  • Modified: Limit number of loaded teams as server returns error for some teams with higher number.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/index.php

    r25 r26  
    9999      if ($Query != null) $URL .= '&query='.$Query;
    100100      if ($StartNumber != null) $URL .= '&startNumber='.$StartNumber;
     101      //echo($URL.'<br/>');
    101102      $Content = file_get_contents($URL);
    102103      $JSON = json_decode($Content, true);
    103       //print_r($JSON);
    104104      return $JSON;
    105105  }
    106106
    107   function QueryRunnersAll($Category = 'all')
     107  function QueryRunnersAll($Category = 'all', $Count = 0)
    108108  {
    109109    $ItemsPerPage = 30;
    110110    $MaxCount = 450 * 30;
     111    if ($Count > 0) $MaxCount = $Count;
    111112    $Result = array();
    112113    $I = 0;
    113114    while (true)
    114115    {
    115       $Page = $I * $MaxCount / $ItemsPerPage;
     116      $Page = $I * floor($MaxCount / $ItemsPerPage);
    116117      $JSON = $this->QueryRunners($Category, $Page, null, null, null, $MaxCount);
    117118      foreach ($JSON['items'] as $Item)
     
    119120        $Result[] = $Item;
    120121      }
    121       if ($JSON['last'] == 'true') break;
     122      if (($JSON['last'] == 'true') or (count($JSON) == 0)) break;
    122123      if ($I > 10) break; // Safe limit if last would not work
    123124      $I++;
     
    278279  {
    279280    $Time = time();
    280     $Items = $this->QueryRunnersAll('teams');
     281    $Items = $this->QueryRunnersAll('teams', 520);
    281282    $Items = array_merge($Items, $this->QueryRunnersAll('families'));
    282283    $Items = array_merge($Items, $this->QueryRunnersAll(''));
     
    287288      $ItemsWithoutProgress[] = $Item;
    288289    }
    289     //print_r($Items);
    290290    $Hash = md5(serialize($ItemsWithoutProgress));
    291291
     
    295295      $Import = $DbResult->fetch_assoc();
    296296    } else $Import = array('Hash' => '');
    297     if ($Import['Hash'] != $Hash)
     297    //if ($Import['Hash'] != $Hash)
    298298    {
    299299      $this->Sync($Items, $Time);
Note: See TracChangeset for help on using the changeset viewer.