[pLog-svn] r578 - plog/trunk/class/summary/dao
subaochen at devel.plogworld.net
subaochen at devel.plogworld.net
Sun Dec 26 03:56:03 GMT 2004
Author: subaochen
Date: 2004-12-26 03:56:02 +0000 (Sun, 26 Dec 2004)
New Revision: 578
Modified:
plog/trunk/class/summary/dao/summarystats.class.php
Log:
1 I think LIKE is more suitable for match ignored topic or text, isn't it?
2 correct wrong parameter order in getReadMostArticles and getCommentedMostArticles
Modified: plog/trunk/class/summary/dao/summarystats.class.php
===================================================================
--- plog/trunk/class/summary/dao/summarystats.class.php 2004-12-26 02:22:47 UTC (rev 577)
+++ plog/trunk/class/summary/dao/summarystats.class.php 2004-12-26 03:56:02 UTC (rev 578)
@@ -37,17 +37,17 @@
* @param ignoreText ignore post based on a certain text
* @return An array of Article objects with the most commented articles
*/
- function getMostCommentedArticles( $maxPosts = 0, $date = 0, $ignoreTopic = "", $ignoreText = "" )
+ function getMostCommentedArticles( $maxPosts = 0, $ignoreTopic = "", $ignoreText = "" ,$date = 0)
{
$query = " SELECT COUNT(*) as total_comments, a.* FROM ".$this->getPrefix()."articles_comments AS c
INNER JOIN ".$this->getPrefix()."articles AS a ON c.article_id=a.id WHERE a.status = ".POST_STATUS_PUBLISHED;
// ignore certain topics and/or certain texts
if( $ignoreTopic != "" )
- $query .= " AND a.topic <> '".Db::qstr( $ignoreTopic )."' ";
+ $query .= " AND a.topic NOT LIKE '%".Db::qstr( $ignoreTopic )."%' ";
if( $ignoreText != "" )
- $query .= " AND a.text <> '".Db::qstr( $ignoreTopic )."' ";
+ $query .= " AND a.text NOT LIKE '%".Db::qstr( $ignoreTopic )."%' ";
$query .= " GROUP BY c.article_id ORDER BY total_comments DESC ";
@@ -78,22 +78,29 @@
* @param ignoreTopic ignore posts based on a certain topic
* @param ignoreText ignore post based on a certain text
* @return an array of Article objects with information about the posts
+ * TODO: perfalmence tuning
*/
- function getMostReadArticles( $maxPosts = 0, $date = 0, $ignoreTopic = "", $ignoreText = "" )
+ function getMostReadArticles( $maxPosts = 0, $ignoreTopic = "", $ignoreText = "", $date = 0 )
{
- $query = " SELECT * FROM ".$this->getPrefix()."articles WHERE status = ".POST_STATUS_PUBLISHED."
- AND TO_DAYS(NOW()) - TO_DAYS(date) < 7 ";
+ $this->log->debug("getMostReadArticles, ignoreTopic is ".$ignoreTopic);
+ $query = " SELECT *
+ FROM ".$this->getPrefix()."articles a, ".$this->getPrefix()."articles_text t
+ WHERE a.id = t.article_id
+ AND status = ".POST_STATUS_PUBLISHED."
+ AND TO_DAYS(NOW()) - TO_DAYS(date) < 7 ";
// ignore certain topics and/or certain texts
if( $ignoreTopic != "" )
- $query .= " AND a.topic <> '".Db::qstr( $ignoreTopic )."' ";
+ $query .= " AND t.topic NOT LIKE '%".Db::qstr( $ignoreTopic )."%' ";
if( $ignoreText != "" )
- $query .= " AND a.text <> '".Db::qstr( $ignoreTopic )."' ";
+ $query .= " AND t.text NOT LIKE '%".Db::qstr( $ignoreText )."%' ";
- $query .= " ORDER BY num_reads DESC ";
+ $query .= " ORDER BY a.num_reads DESC ";
+ $this->log->debug("getMostReadArticles, query is ".$query);
+
if( $maxPosts > 0 )
$query .= " LIMIT 0,".$maxPosts;
@@ -350,11 +357,11 @@
// in case we'd like to ignore certain posts based on a topic (like the registration message!)
if( $ignoreTopic != "" ) {
- $query .= " AND t.topic <> '".Db::qstr( $ignoreTopic )."' ";
+ $query .= " AND t.topic NOT LIKE '%".Db::qstr( $ignoreTopic )."%' ";
}
// in case we'd like to ignore certain posts based on their contents (like the registration message!)
if( $ignoreText != "" ) {
- $query .= " AND t.text <> '".Db::qstr( $ignoreText )."' ";
+ $query .= " AND t.text NOT LIKE '%".Db::qstr( $ignoreText )."%' ";
}
$query .= " GROUP BY a.id HAVING COUNT(a.blog_id) = 1 ORDER BY a.date DESC LIMIT 0, $maxPosts";
More information about the pLog-svn
mailing list