You are here

public function FeedsSource::progressImporting in Feeds 7.2

Report progress as float between 0 and 1. 1 = FEEDS_BATCH_COMPLETE.

2 calls to FeedsSource::progressImporting()
FeedsSource::import in includes/FeedsSource.inc
Import a source: execute fetching, parsing and processing stage.
FeedsSource::scheduleImport in includes/FeedsSource.inc
Schedule periodic or background import tasks.

File

includes/FeedsSource.inc, line 691
Definition of FeedsSourceInterface, FeedsState and FeedsSource class.

Class

FeedsSource
Holds the source of a feed to import.

Code

public function progressImporting() {
  $fetcher = $this
    ->state(FEEDS_FETCH);
  $parser = $this
    ->state(FEEDS_PARSE);
  if ($fetcher->progress == FEEDS_BATCH_COMPLETE && $parser->progress == FEEDS_BATCH_COMPLETE) {
    return FEEDS_BATCH_COMPLETE;
  }

  // Fetching envelops parsing.
  // @todo: this assumes all fetchers neatly use total. May not be the case.
  $fetcher_fraction = $fetcher->total ? 1.0 / $fetcher->total : 1.0;
  $parser_progress = $parser->progress * $fetcher_fraction;
  $result = $fetcher->progress - $fetcher_fraction + $parser_progress;
  if ($result == FEEDS_BATCH_COMPLETE) {
    return 0.99;
  }
  return $result;
}