Skip to content

Commit

Permalink
Ignore the active field on the follows table for recent user versions…
Browse files Browse the repository at this point in the history
… query.
  • Loading branch information
cdmoyer authored and ginatrapani committed Sep 4, 2014
1 parent 2163eab commit 461d9f8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions tests/TestOfUserVersionsMySQLDAO.php
Expand Up @@ -118,8 +118,9 @@ public function testGetRecentFriendsVersions() {
'field_value' => 'http://foo.bar', 'crawl_time' => '-28h'));
$builders[] = FixtureBuilder::build('follows', array('active' => 1, 'user_id' => 22,
'follower_id' => 11, 'network' => 'twitter'));
$builders[] = FixtureBuilder::build('follows', array('active' => 0, 'user_id' => 33,
'follower_id' => 11, 'network' => 'twitter'));
// TODO: Restore this fixture to test inactives, when active follows bug is fixed.
// $builders[] = FixtureBuilder::build('follows', array('active' => 0, 'user_id' => 33,
// 'follower_id' => 11, 'network' => 'twitter'));
$builders[] = FixtureBuilder::build('users', array('network'=>'twitter','id'=>1,'user_id'=>11));
$builders[] = FixtureBuilder::build('users', array('network'=>'twitter','id'=>2,'user_id'=>22));
$builders[] = FixtureBuilder::build('users', array('network'=>'twitter','id'=>3,'user_id'=>33));
Expand Down
3 changes: 2 additions & 1 deletion webapp/_lib/dao/class.UserVersionsMySQLDAO.php
Expand Up @@ -56,11 +56,12 @@ public function getRecentFriendsVersions($user_key, $past_x_days, $fields = arra
':days_ago' =>$past_x_days
);

// TODO: Check f.active in follows sub-select when the active bug is fixed.
$q = "SELECT user_key, field_name, field_value, crawl_time FROM #prefix#user_versions uv ";
$q .= "WHERE crawl_time > date_sub(NOW(), INTERVAL :days_ago day) ";
$q .= "AND user_key IN (SELECT id FROM #prefix#users u LEFT JOIN #prefix#follows f ON ";
$q .= " (f.network=u.network AND u.user_id=f.user_id) ";
$q .= " WHERE f.follower_id=:user_id AND f.network=:network AND f.active=1) ";
$q .= " WHERE f.follower_id=:user_id AND f.network=:network ) ";
if (count($fields)) {
$q .= " AND field_name IN (";
$tojoin = array();
Expand Down

0 comments on commit 461d9f8

Please sign in to comment.