Changeset 1667 for trunk

Show
Ignore:
Timestamp:
05/07/10 05:59:40 (2 years ago)
Author:
nick_ramsay
Message:

[TRUNK] Hotaru 1.2 updates for improved caching.

Location:
trunk
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/content/plugins

  • trunk/content/plugins/sb_base/libs/SbBaseFunctions.php

    r1662 r1667  
    149149            $h->vars['filter']['post_archived = %s'] = 'N';  
    150150            $h->vars['filter']['post_status = %s'] = 'new';  
    151             $start = date('YmdHis', strtotime("now")); 
     151            $start = date('YmdHis', time_block()); 
    152152            $end = date('YmdHis', strtotime($upcoming_duration)); // should be negative 
    153153            $h->vars['filter']['(post_date >= %s AND post_date <= %s)'] = array($end, $start);  
     
    158158            // Filters page to "top" stories from the last 24 hours only 
    159159            $h->vars['filter']['post_status = %s'] = 'top';  
    160             $start = date('YmdHis', strtotime("now")); 
     160            $start = date('YmdHis', time_block()); 
    161161            $end = date('YmdHis', strtotime("-1 day")); 
    162162            $h->vars['filter']['(post_date >= %s AND post_date <= %s)'] = array($end, $start);  
     
    167167            // Filters page to "top" stories from the last 48 hours only 
    168168            $h->vars['filter']['post_status = %s'] = 'top';  
    169             $start = date('YmdHis', strtotime("now")); 
     169            $start = date('YmdHis', time_block()); 
    170170            $end = date('YmdHis', strtotime("-2 days")); 
    171171            $h->vars['filter']['(post_date >= %s AND post_date <= %s)'] = array($end, $start);  
     
    176176            // Filters page to "top" stories from the last 7 days only 
    177177            $h->vars['filter']['post_status = %s'] = 'top';  
    178             $start = date('YmdHis', strtotime("now")); 
     178            $start = date('YmdHis', time_block()); 
    179179            $end = date('YmdHis', strtotime("-7 days")); 
    180180            $h->vars['filter']['(post_date >= %s AND post_date <= %s)'] = array($end, $start);  
     
    185185            // Filters page to "top" stories from the last 30 days only 
    186186            $h->vars['filter']['post_status = %s'] = 'top';  
    187             $start = date('YmdHis', strtotime("now")); 
     187            $start = date('YmdHis', time_block()); 
    188188            $end = date('YmdHis', strtotime("-30 days")); 
    189189            $h->vars['filter']['(post_date >= %s AND post_date <= %s)'] = array($end, $start);  
     
    194194            // Filters page to "top" stories from the last 365 days only 
    195195            $h->vars['filter']['post_status = %s'] = 'top';  
    196             $start = date('YmdHis', strtotime("now")); 
     196            $start = date('YmdHis', time_block()); 
    197197            $end = date('YmdHis', strtotime("-365 days")); 
    198198            $h->vars['filter']['(post_date >= %s AND post_date <= %s)'] = array($end, $start);  
  • trunk/content/plugins/sb_base/readme.txt

    r1662 r1667  
    1414Changelog 
    1515--------- 
     16v.1.0 2010/05/07 - Nick - Fixes for better caching 
    1617v.1.0 2010/04/14 - Nick - Changes to enable home page overriding 
    1718v.0.9 2010/03/27 - Nick - 1 & 3 month options for post archiving, plus reorganization of post RSS methods 
  • trunk/functions/funcs.times.php

    r1662 r1667  
    149149        } 
    150150} 
     151 
     152 /** 
     153 * Returns the next time block of the day, e.g. now: 1:25, so returns 2:00 (if block = 1 hour) 
     154 * 
     155 * @param int $block - time in HOURS 
     156 * @return int - time in SECONDS 
     157 */ 
     158function time_block($block = 1) 
     159{ 
     160        $block = ($block * 60) * 60; // change into seconds 
     161        $time_now = time(); 
     162        $start_of_current_block = floor($time_now/$block); 
     163        $start_of_current_block *= $block; 
     164         
     165        $start_of_next_block = $start_of_current_block + $block; 
     166         
     167        return $start_of_next_block; 
     168} 
    151169?> 
  • trunk/libs/Comment.php

    r1662 r1667  
    536536        public function countDailyComments($h) 
    537537        { 
    538                 $start = date('YmdHis', strtotime("now")); 
     538                $start = date('YmdHis', time_block()); 
    539539                $end = date('YmdHis', strtotime("-1 day")); 
    540540                $sql = "SELECT COUNT(comment_id) FROM " . TABLE_COMMENTS . " WHERE comment_archived = %s AND comment_user_id = %d AND (comment_date >= %s AND comment_date <= %s)"; 
  • trunk/libs/Post.php

    r1664 r1667  
    413413                }  
    414414                 
    415                 $start = date('YmdHis', strtotime("now")); 
     415                $start = date('YmdHis', time_block()); 
    416416                $end = date('YmdHis', strtotime($time_ago)); 
    417417                $sql = "SELECT COUNT(post_id) FROM " . TABLE_POSTS . " WHERE post_archived = %s AND post_author = %d AND post_type = %s AND (post_date >= %s AND post_date <= %s)";