Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove unused PostDAO function added in d82eef8
  • Loading branch information
ginatrapani committed Jun 6, 2012
1 parent d82eef8 commit 8a78dad
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 70 deletions.
38 changes: 0 additions & 38 deletions tests/TestOfPostMySQLDAO.php
Expand Up @@ -2831,44 +2831,6 @@ public function testUpdatePostText() {
$this->assertEqual($post->post_text, 'This is updated post 10');
}

public function testGetAverageRetweetCount() {
$builders = array();
//Add straight text posts
$counter = 1;
while ($counter < 40) {
$pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT);
if ($counter % 3 == 0) {
$source = '<a href="http://twitter.com" rel="nofollow">Tweetie for Mac</a>';
} else if ($counter % 3 == 1) {
$source = '<a href="http://twitter.com/tweetbutton" rel="nofollow">Tweet Button</a>';
} else {
$source = 'web';
}
$builders[] = FixtureBuilder::build('posts', array('id'=>$counter+256, 'post_id'=>$counter+256,
'author_user_id'=>'13', 'author_username'=>'ev', 'author_fullname'=>'Ev Williams',
'author_avatar'=>'avatar.jpg', 'post_text'=>'This is post '.$counter,
'source'=>$source, 'pub_date'=>'-'.$counter.'d', 'in_reply_to_user_id'=>null,
'reply_count_cache'=>($counter==10)?0:rand(0, 4), 'is_protected'=>0,
'retweet_count_cache'=>floor($counter/2), 'network'=>'twitter',
'old_retweet_count_cache' => floor($counter/3), 'in_rt_of_user_id' => null,
'in_reply_to_post_id'=>null, 'in_retweet_of_post_id'=>null, 'is_geo_encoded'=>0));
$counter++;
}

$dao = new PostMySQLDAO();
//without date (today)
$average_retweet_count = $dao->getAverageRetweetCount('ev', 'twitter', 7);
$this->assertEqual($average_retweet_count, 3);

//yesterday
$average_retweet_count = $dao->getAverageRetweetCount('ev', 'twitter', 7, date("Y-m-d", strtotime("-1 day")));
$this->assertEqual($average_retweet_count, 4);

//40 days ago
$average_retweet_count = $dao->getAverageRetweetCount('ev', 'twitter', 7, date("Y-m-d", strtotime("-40 day")));
$this->assertEqual($average_retweet_count, 17);
}

public function testGetAllPostsFromThisDayYearAgo(){
// Generate the date string for 1 year ago today
$year_ago_date = date(date( 'Y-m-d H:i:s' , strtotime("today -1 year")));
Expand Down
22 changes: 0 additions & 22 deletions webapp/_lib/model/class.PostMySQLDAO.php
Expand Up @@ -1673,28 +1673,6 @@ public function updatePostText($post_id, $network, $post_text) {
return $this->getUpdateCount($ps);
}

public function getAverageRetweetCount($author_username, $network, $last_x_days, $since=null){
if ($since==null) {
$since = date('Y-m-d');
}

$q = "SELECT round(avg(old_retweet_count_cache + retweet_count_cache)) as average_retweet_count ";
$q .= "FROM #prefix#posts WHERE network=:network and author_username=:author_username ";
$q .= "AND in_reply_to_user_id IS null AND in_reply_to_post_id IS null AND in_retweet_of_post_id is null ";
$q .= "AND (retweet_count_cache > 0 OR old_retweet_count_cache > 0) ";
$q .= "AND pub_date >= DATE_SUB(:since, INTERVAL :last_x_days DAY);";
$vars = array(
':author_username'=>$author_username,
':network'=>$network,
':last_x_days'=>(int)$last_x_days,
':since'=>$since
);
if ($this->profiler_enabled) Profiler::setDAOMethod(__METHOD__);
$ps = $this->execute($q, $vars);
$result = $this->getDataRowAsArray($ps);
return $result["average_retweet_count"];
}

public function getPostsFromThisDayThatYear($author_id, $network, $year, $from_date=null) {
$vars = array(
':year'=> $year,
Expand Down
10 changes: 0 additions & 10 deletions webapp/_lib/model/interface.PostDAO.php
Expand Up @@ -564,16 +564,6 @@ public function getPostsToUser($user_id, $network, $count = 15, $page = 1, $is_p
*/
public function getPostsToUserIterator($user_id, $network, $count, $is_public=false);

/**
* Get the average retweet count over the last X days
* @param $username
* @param $network
* @param $last_x_days
* @param $since Date to calculate from defaults to today
* @return int Average retweet count over the last X days
*/
public function getAverageRetweetCount($username, $network, $last_x_days, $since=null);

/**
* Get posts from this day in a given year that aren't replies or reshares/retweets.
* @param str $author_id
Expand Down

0 comments on commit 8a78dad

Please sign in to comment.