Commit 5199f1bb authored by Dries's avatar Dries
Browse files

- Patch #394582 by Berdir: converted to new database abstraction layer.

parent f13d5024
......@@ -14,23 +14,22 @@ function tracker_page($account = NULL, $set_title = FALSE) {
// Add CSS
drupal_add_css(drupal_get_path('module', 'tracker') . '/tracker.css', array('preprocess' => FALSE));
$header = array(
t('Type'),
t('Post'),
t('Author'),
t('Replies'),
t('Last updated')
);
$header = array(t('Type'), t('Post'), t('Author'), t('Replies'), t('Last updated'));
// TODO: These queries are very expensive, see http://drupal.org/node/105639
$query = db_select('node', 'n', array('target' => 'slave'))
->fields('n', array('nid', 'title', 'type', 'changed', 'uid'));
$query = db_select('node', 'n', array('target' => 'slave'))->extend('PagerDefault');
$query->join('users', 'u', 'n.uid = u.uid');
$query->addField('u', 'name');
$query->join('node_comment_statistics', 'l', 'n.nid = l.nid');
$query->addExpression('GREATEST(n.changed, l.last_comment_timestamp)', 'last_updated');
$query->addField('l', 'comment_count');
$query->orderBy('last_updated', 'DESC');
$query
->distinct()
->fields('n', array('nid', 'title', 'type', 'changed', 'uid'))
->fields('u', array('name'))
->fields('l', array('comment_count'))
->condition('n.status', 1)
->orderBy('last_updated', 'DESC')
->addTag('node_access')
->limit(25);
if ($account) {
if ($set_title) {
......@@ -46,12 +45,6 @@ function tracker_page($account = NULL, $set_title = FALSE) {
);
}
$query->condition('n.status', 1);
$query->distinct();
$query->extend('PagerDefault')->extend('TableSort')
->limit(25, 0)
->orderByHeader($header);
$result = $query->execute();
$rows = array();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment