Skip to content

Commit

Permalink
Display total likes in Biggest Fans insight [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
ginatrapani committed Aug 17, 2012
1 parent f191158 commit b9d4ac7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion webapp/_lib/controller/class.InsightStreamController.php
Expand Up @@ -42,7 +42,7 @@ public function control() {
if (Session::isLoggedIn()) {
if ($this->isAdmin()) {
///show all insights for all service users
$insights = $insight_dao->getAllInstanceInsights($page_count=10, $page);
$insights = $insight_dao->getAllInstanceInsights($page_count=20, $page);
$this->addToView('insights', $insights);
} else {
//show only service users owner owns
Expand Down
17 changes: 12 additions & 5 deletions webapp/_lib/model/class.FavoritePostMySQLDAO.php
Expand Up @@ -365,15 +365,15 @@ public function getFavoritesFromOneYearAgo($fav_of_user_id, $network, $from_date
}

public function getUsersWhoFavoritedMostOfYourPosts($author_user_id, $network, $last_x_days) {
//$q = "SELECT u.user_name, fav_of_user_id, count(f.post_id) AS total_favs from tu_favorites f ";
//$q = "SELECT u.user_name, fav_of_user_id, count(f.post_id) AS total_likes from tu_favorites f ";
$q = "SELECT * FROM ( ";
$q .= "SELECT u.*, count(f.post_id) AS total_favs from tu_favorites f ";
$q .= "SELECT u.*, count(f.post_id) AS total_likes from tu_favorites f ";
$q .= "INNER JOIN tu_users u ON u.user_id = f.fav_of_user_id ";
$q .= "INNER JOIN tu_posts p ON f.post_id = p.post_id ";
$q .= "WHERE f.author_user_id = :author_user_id and f.network=:network ";
$q .= "AND p.pub_date >= date_sub(current_date, INTERVAL :last_x_days day) ";
$q .= "GROUP BY f.fav_of_user_id ORDER BY total_favs DESC";
$q .= ") favs WHERE favs.total_favs > 1 LIMIT 3";
$q .= "GROUP BY f.fav_of_user_id ORDER BY total_likes DESC";
$q .= ") favs WHERE favs.total_likes > 1 LIMIT 3";

$vars = array(
':author_user_id'=> $author_user_id,
Expand All @@ -385,6 +385,13 @@ public function getUsersWhoFavoritedMostOfYourPosts($author_user_id, $network, $
if ($this->profiler_enabled) Profiler::setDAOMethod(__METHOD__);

$ps = $this->execute($q, $vars);
return $this->getDataRowsAsObjects($ps, 'User');
$rows = $this->getDataRowsAsArrays($ps);
$users = array();
foreach ($rows as $row) {
$user = new User($row);
$user->total_likes = $row['total_likes'];
$users[] = $user;
}
return $users;
}
}
2 changes: 1 addition & 1 deletion webapp/_lib/view/_insights.users.tpl
Expand Up @@ -16,7 +16,7 @@
<span style="color:gray">{$u->description|link_usernames_to_twitter}</span>
{$u->url}<br>
{else}
{$u->full_name}<br><br><br>
{$u->full_name}{if $u->other.total_likes}<br><small style="color:gray">{$u->other.total_likes|number_format} likes</small>{/if}<br><br><br>
{/if}
</div>
<div style="clear:all">&nbsp;</div>
Expand Down

0 comments on commit b9d4ac7

Please sign in to comment.