Ignore:
Timestamp:
May 27, 2020, 8:04:56 PM (5 years ago)
Author:
chronos
Message:
  • Added: Allow to disable MeetSource in database.
  • Added: Show how many meet items were parsed and how many new added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Meet/Meet.php

    r55 r57  
    326326  {
    327327    $Output = '';
    328     if (($Id != null) and is_numeric($Id)) $Where = 'Id='.$Id;
    329       else $Where = '1';
     328    $Where = '(Enabled=1)';
     329    if (($Id != null) and is_numeric($Id)) $Where .= ' AND (Id='.$Id.')';
    330330    $DbResult = $this->Database->select('MeetSource', '*', $Where);
    331331    while ($DbRow = $DbResult->fetch_assoc())
     
    353353      $Source->Name = $DbRow['Name'];
    354354      $this->Items[] = $Source;
    355       $Output .= $Source->Import();
     355      $Output .= $Source->DoImport();
    356356    }
    357357    return $Output;
     
    366366  public $Id;
    367367  public $Database;
     368  public $MeetItems;
     369  public $AddCompareTime;
     370  public $AddCompareRemoteId;
     371  public $AddTimeInterval;
     372  public $AddedCount;
     373
     374  function __construct()
     375  {
     376    $this->MeetItems = array();
     377    $this->AddedCount = 0;
     378    $this->AddCompareTime = true;
     379    $this->AddCompareRemoteId = false;
     380    $this->AddTimeInterval = 0;
     381  }
    368382
    369383  function Import()
    370384  {
     385    return '';
     386  }
     387
     388  function DoImport()
     389  {
     390    $this->MeetItems = array();
    371391    $this->AddedCount = 0;
    372     $Output = 'Parsing '.$this->Name.' ('.$this->Id.')...</br>';
     392    $Output = 'Parsing '.$this->Name.' (#'.$this->Id.')...';
     393    $Output .= $this->Import();
     394    $Output .= ' parsed: '.count($this->MeetItems);
     395    foreach ($this->MeetItems as $MeetItem)
     396    {
     397      $this->AddedCount += $MeetItem->AddIfNotExist($this->AddTimeInterval, $this->AddCompareTime, $this->AddCompareRemoteId);
     398    }
     399    $Output .= ', new added: '.$this->AddedCount;
     400    $Output .= '</br>'."\n";
    373401    return $Output;
    374402  }
Note: See TracChangeset for help on using the changeset viewer.