Recently Popular Order
| Project: | DrupalIt |
| Version: | 5.x-1.4-beta2 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Why is the recently popular block not showing or listing items by last vote date?
For example: If an item becomes recently popular because it was voted on now/today then the Recently Popular block should show the item just voted on at the top of the block. It is not and I'm not sure what the reasoning was for using first_vote in the query which appears to be used for when a node is first voted on vs. last_vote in the query which seems more logical as it would properly display the most recent items voted on.
Here is a snippet of a recently votes statistics page:
Title Total votes Last Day Last Week Last Month First Vote Last Vote
Deepika Padukone 2 0 0 2 Jun 03 2009 03:03 Jun 09 2009 12:00
Sophie Howard 2 0 0 1 Jan 28 2009 02:08 Jun 13 2009 08:29
The way the current 5.x drupalit latest block works would list result as (because of the more recent first vote date):
1. Deepika Padukone
2. Sophie Howard
vs. What seems like it should be (based on the most recent/last vote date):
1. Sophie Howard
2. Deepika Padukone

#1
I found the code that seems illogical unless otherwise clarified. Recommend changing to the following function to use the last_vote column vs. the first_vote column. This is in the drupalit.module
Starting on line 638 - 654
function theme_drupalit_newly_block($delta) {
$days = variable_get('drupalit_days_'.$delta, '7');
$daysstamp = $days*86400;
$now = time();
$votes = variable_get('drupalit_votes_'.$delta, '10');
$result = db_query("SELECT dv.nid, dv.votes, n.title FROM {drupalit_votes} dv INNER JOIN {node} n ON dv.nid = n.nid WHERE dv.votes > %d AND (dv.last_vote + %d > %d) ORDER BY dv.last_vote DESC LIMIT %d", $votes, $daysstamp, $now, variable_get('drupalit_block_links_'.$delta, '5'));
$show_details = variable_get('drupalit_details_'.$delta, '');
$more_link = variable_get('drupalit_more_link_'.$delta, '');
$output = '<div class="item-list"><ul>';
while ($latest = db_fetch_array($result)) {
$output .= '<li>'.l($latest['title'], 'node/'.$latest['nid']).($details = ($show_details) ? ' ('.format_plural($latest['votes'], '1 vote', '@count votes').')' : '').'</li>';
}
$output .= '</ul></div>';
$output .= ($more_link) ? '<div class="more-link">'.l(t('more...'), 'drupalit/newly').'</div>' : '';
return $output;
}