$def with (stats) $var title: $_("Imports") $ recache = query_param('recache', False) $ component_times = {} $ component_times['TotalTime'] = time()
$if ctx.user and ctx.user.is_admin(): $:render_template("admin/menu")

$_("Imports")

$if ctx.user and ctx.user.is_admin():
$_("Add new books to import queue")

$_("New Books Imported Per Day")

$_("Summary")

$ component_times['stats.get_count'] = time() $ pending_count = stats.get_count(status='pending', use_cache=not recache) $ component_times['stats.get_count'] = time() - component_times['stats.get_count'] $_("Pending Items:") $pending_count

$ component_times['stats.get_imports_per_hour'] = time() $ rate = stats.get_imports_per_hour() $ component_times['stats.get_imports_per_hour'] = time() - component_times['stats.get_imports_per_hour'] $:_('Current Import Rate: %(num)d imports/hour.', num=rate)

$_("ETA:") $if rate: $ eta = pending_count*1.0 / rate ${"%.2f" % eta} hours $else: -

$_("Summary By Date")

$ component_times['stats.get_count_by_date_status'] = time() $ status_counts = stats.get_count_by_date_status(use_cache=not recache) $ component_times['stats.get_count_by_date_status'] = time() - component_times['stats.get_count_by_date_status'] $for date, counts in status_counts:
$_("Date") $_("total") $_("#books created") $_("#books already found") $_("#books failed to import") $_("#books pending")
$date $sum(counts.values()) $counts.get('created', 0) ${counts.get('found', 0) + counts.get('modified', 0)} $counts.get('failed', 0) $counts.get('pending', 0)

$_("Recent Imports")

$ component_times['stats.get_items'] = time() $ import_items = stats.get_items(order="import_time desc", limit=20) $ component_times['stats.get_items'] = time() - component_times['stats.get_items'] $for row in import_items:
# $_("Identifier") $_("OL Key") $_("Status") $_("Error") $_("Added Time") $_("Imported Time")
$loop.index $truncate(row.ia_id, 40) $if row.ol_key: $row.ol_key.split("/")[-1] $else: - $row.status ${row.error or '-'} $datestr(row.added_time) $datestr(row.import_time)
$ component_times['stats.get_books_imported_per_day'] = time() $ component_times['stats.get_books_imported_per_day'] = time() - component_times['stats.get_books_imported_per_day'] $ component_times['TotalTime'] = time() - component_times['TotalTime'] $if query_param('debug'): $:macros.Profile(component_times)