function feedapi_admin_overview in FeedAPI 6
Same name and namespace in other branches
- 5 feedapi.module \feedapi_admin_overview()
Provide a UI for overviewing the existing feeds
1 string reference to 'feedapi_admin_overview'
- feedapi_menu in ./
feedapi.module - Implementation of hook_menu().
File
- ./
feedapi.admin.inc, line 11 - Administration-related functions for FeedAPI
Code
function feedapi_admin_overview() {
$header = array(
t('Title'),
t('New items added per update'),
t('Update rate'),
t('Number of items'),
t('Processing time'),
t('Commands'),
);
$rows = array();
$result = pager_query("SELECT nid from {feedapi} ORDER BY next_refresh_time DESC", 50, 0, "SELECT count(*) FROM {feedapi}");
while ($nid = db_fetch_array($result)) {
$nid = $nid['nid'];
$node = node_load($nid);
if (is_object($node)) {
$commands = array(
l(t('Delete'), 'node/' . $node->nid . '/delete', array(
'query' => 'destination=admin/content/feed',
)),
l(t('Remove items'), 'node/' . $node->nid . '/purge', array(
'query' => 'destination=admin/content/feed',
)),
l(t('Refresh'), 'node/' . $node->nid . '/refresh'),
l(t('Edit'), 'node/' . $node->nid . '/edit'),
);
// Fetch statistics for this feed
foreach (array(
'download_num',
'new',
'process_time',
'update_times',
) as $type) {
$node->feed->statistics[$type] = _feedapi_get_stat($node->nid, $type, TRUE);
}
if (count($node->feed->statistics['download_num']) != 0 && count($node->feed->statistics['new']) != 0 && count($node->feed->statistics['process_time']) != 0) {
$update_rate = _feedapi_update_rate($node->feed->statistics['update_times']);
$rows[] = array(
l($node->title, "node/{$node->nid}"),
round(array_sum($node->feed->statistics['new']) / count($node->feed->statistics['new']), 2),
is_numeric($update_rate) ? format_interval($update_rate) : $update_rate,
round(array_sum($node->feed->statistics['download_num']) / count($node->feed->statistics['download_num']), 2),
round(array_sum($node->feed->statistics['process_time']) / count($node->feed->statistics['process_time']), 2) . ' ' . t('ms'),
theme('item_list', $commands),
);
}
else {
$rows[] = array(
l($node->title, "node/{$node->nid}"),
'',
'',
t('No enough data for statistics'),
'',
theme('item_list', $commands),
);
}
}
}
$output = format_plural(round(FEEDAPI_CRON_STAT_LIFETIME / (24 * 3600)), "Average over the last day.", "Averages over the last @count days.");
$output .= theme('table', $header, $rows);
$output .= theme('pager', 0, 50);
return $output;
}