Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1945-geo-analysis-facebook #2038

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
32fca9b
Changed mail setting
May 29, 2014
453d706
Added gender field. Gender field prosessing in DAO classes.
May 29, 2014
3359c46
Changes for gender field in Crawler
Jun 1, 2014
a56bc6f
Gender field tests in TestOfFacebookCrawler
Jun 4, 2014
a4eded9
Getting data from DB for gender analysis
Jun 8, 2014
99232ff
Created template for gender analysis
Jun 8, 2014
f1351dc
finish gender analysis tpl and php
Jun 15, 2014
6106e3c
sql changes for birthday field
Jun 15, 2014
2025b6c
TestOfUserMySQLDAO changes for birthday field
Jun 15, 2014
ac7f15a
changed testdata and TestOfFacebookCrawler for birthday field
Jun 15, 2014
6f6494d
getAgeOfFavoriters and getAgeOfCommenters functions added
Jun 16, 2014
d292ab0
chenged domentation
Jun 17, 2014
d5cf196
call gender analysis every day
Jun 17, 2014
2c01870
corrections
Jun 17, 2014
2023935
Tests for gender analysis
Jun 18, 2014
30b3f3d
fixed merge conflict
Jun 18, 2014
6a480bc
fixed merge conflict2
Jun 18, 2014
e629250
fixed merge conflict2
Jun 18, 2014
bb3ea85
Age analysis insight php and tpl
Jun 19, 2014
6b40046
Tests for age analysis, php and tpl corrections after tests
Jun 19, 2014
e739d01
Some corrections for age analysis in php, tpl and tests
Jun 19, 2014
703cf36
corrections
Jun 19, 2014
a9b422a
first fersion of php and tpl for geo analysis
Jun 20, 2014
6245693
finished php and tpl for geo analysis
Jul 8, 2014
dc6a1bb
tests and query changes
Jul 13, 2014
2968cb6
add TestOfGeoAnalysisFacebookInsight
Jul 13, 2014
16b0073
corrections
Jul 22, 2014
21366ca
bug fix
Aug 8, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,120 changes: 678 additions & 442 deletions tests/TestOfFavoritePostMySQLDAO.php

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions tests/TestOfPostMySQLDAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -4064,6 +4064,42 @@ public function testCountAllPostsByUserSinceDaysAgo() {

$this->assertEqual($result, 32);
}

public function testGetMostFavCommentPostsByUserId() {
echo "start test\n";
$builders = array();
$user_id=7654321;
$now = date('Y-m-d H:i:s');
$yesterday = date('Y-m-d H:i:s', strtotime('yesterday'));
$builders[] = FixtureBuilder::build('posts', array('id'=> 331, 'post_id'=> 1331, 'author_user_id'=>$user_id,
'author_username'=>'user', 'author_fullname'=>'User', 'author_avatar'=>'avatar.jpg',
'network'=>'facebook', 'post_text'=>'This is a simple post.',
'pub_date'=>$now, 'reply_count_cache'=> 1,'favlike_count_cache' => 6));

$builders[] = FixtureBuilder::build('posts', array('id'=> 341, 'post_id'=> 1341, 'author_user_id'=>$user_id,
'author_username'=>'user', 'author_fullname'=>'User', 'author_avatar'=>'avatar.jpg',
'network'=>'facebook', 'post_text'=>'This is a simple comment.',
'pub_date'=>$now, 'reply_count_cache'=> 0,'favlike_count_cache' => 5));

$builders[] = FixtureBuilder::build('posts', array('id'=> 351, 'post_id'=> 1351, 'author_user_id'=>$user_id,
'author_username'=>'user', 'author_fullname'=>'User', 'author_avatar'=>'avatar.jpg',
'network'=>'facebook', 'post_text'=>'This is a simple cooment.',
'pub_date'=>$yesterday, 'reply_count_cache'=> 0,'favlike_count_cache' => 4));

$builders[] = FixtureBuilder::build('posts', array('id'=> 361, 'post_id'=> 1361, 'author_user_id'=>$user_id,
'author_username'=>'user', 'author_fullname'=>'User', 'author_avatar'=>'avatar.jpg',
'network'=>'facebook', 'post_text'=>'This is a simple comment.',
'pub_date'=>$now, 'reply_count_cache'=> 0,'favlike_count_cache' => 0));

$post_dao = new PostMySQLDAO();
$posts = $post_dao->getMostFavCommentPostsByUserId($user_id, 'facebook');
$this-> assertNotNull($posts);
foreach($posts as $post) {
$this->assertTrue($post instanceof Post);
$this->assertEqual($post->post_id, '1331');
}

}

public function testSearchPostsByUsername() {
$post_dao = new PostMySQLDAO();
Expand Down
36 changes: 27 additions & 9 deletions tests/TestOfUserMySQLDAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public function setUp() {
protected function buildData() {
//Insert test data into test table
$builders[] = FixtureBuilder::build('users', array('user_id'=>12, 'user_name'=>'jack',
'full_name'=>'Jack Dorsey', 'avatar'=>'avatar.jpg', 'location'=>'San Francisco',
'full_name'=>'Jack Dorsey', 'avatar'=>'avatar.jpg', 'gender'=>'', 'birthday'=>'', 'location'=>'San Francisco',
'is_verified'=>1, 'network'=>'twitter'));

//Insert test data into test table
$builders[] = FixtureBuilder::build('users', array('user_id'=>13, 'user_name'=>'zuck',
'full_name'=>'Mark Zuckerberg', 'avatar'=>'avatar.jpg', 'location'=>'San Francisco',
'network'=>'facebook'));

'full_name'=>'Mark Zuckerberg', 'avatar'=>'avatar.jpg', 'gender'=>'Male', 'birthday'=>'06/11/1992',
'location'=>'San Francisco', 'network'=>'facebook'));
$this->logger = Logger::getInstance();
return $builders;
}
Expand Down Expand Up @@ -102,11 +102,15 @@ public function testGetDetailsUserExists() {
$this->assertEqual($user->id, 1);
$this->assertEqual($user->user_id, 12);
$this->assertEqual($user->username, 'jack');
$this->assertEqual($user->gender, '');
$this->assertEqual($user->birthday, '');
$this->assertEqual($user->network, 'twitter');
$user = $user_dao->getDetails(13, 'facebook');
$this->assertEqual($user->id, 2);
$this->assertEqual($user->user_id, 13);
$this->assertEqual($user->username, 'zuck');
$this->assertEqual($user->gender, 'Male');
$this->assertEqual($user->birthday, '06/11/1992');
$this->assertEqual($user->network, 'facebook');

$user = $user_dao->getDetails(13, 'twitter');
Expand All @@ -129,7 +133,7 @@ public function testUpdateUser() {
$user_dao = DAOFactory::getDAO('UserDAO');

$user_array = array('user_id'=>'13', 'user_name'=>'ginatrapani', 'full_name'=>'Gina Trapani',
'avatar'=>'avatar.jpg', 'location'=>'NYC', 'description'=>'Blogger', 'url'=>'http://ginatrapani.org',
'avatar'=>'avatar.jpg', 'gender'=>'', 'birthday'=>'', 'location'=>'NYC', 'description'=>'Blogger', 'url'=>'http://ginatrapani.org',
'is_verified'=>1, 'is_protected'=>0, 'follower_count'=>5000, 'post_count'=>1000,
'joined'=>'2007-03-06 13:48:05', 'network'=>'twitter', 'last_post_id'=>'abc102');
$user = new User($user_array, 'Test Insert');
Expand All @@ -138,11 +142,13 @@ public function testUpdateUser() {
$this->assertEqual($user_from_db->user_id, '13');
$this->assertEqual($user_from_db->username, 'ginatrapani');
$this->assertEqual($user_from_db->avatar, 'avatar.jpg');
$this->assertEqual($user_from_db->gender, '');
$this->assertEqual($user_from_db->birthday, '');
$this->assertEqual($user_from_db->location, 'NYC');
$this->assertTrue($user_from_db->is_verified);

$user_array = array('user_id'=>13, 'user_name'=>'ginatrapanichanged', 'full_name'=>'Gina Trapani ',
'avatar'=>'avatara.jpg', 'location'=>'San Diego', 'description'=>'Blogger', 'url'=>'http://ginatrapani.org',
'avatar'=>'avatara.jpg', 'gender'=>'', 'birthday'=>'', 'location'=>'San Diego', 'description'=>'Blogger', 'url'=>'http://ginatrapani.org',
'is_verified'=>0, 'is_protected'=>0, 'follower_count'=>5000, 'post_count'=>1000,
'joined'=>'2007-03-06 13:48:05', 'network'=>'twitter');
$user1 = new User($user_array, 'Test Update');
Expand All @@ -151,12 +157,14 @@ public function testUpdateUser() {
$this->assertEqual($user_from_db->user_id, 13);
$this->assertEqual($user_from_db->username, 'ginatrapanichanged');
$this->assertEqual($user_from_db->avatar, 'avatara.jpg');
$this->assertEqual($user_from_db->gender, '');
$this->assertEqual($user_from_db->birthday, '');
$this->assertEqual($user_from_db->location, 'San Diego');
$this->assertFalse($user_from_db->is_verified);

//Test no username set
$user_array = array('user_id'=>13, 'user_name'=>null, 'full_name'=>'Gina Trapani ',
'avatar'=>'avatara.jpg', 'location'=>'San Diego', 'description'=>'Blogger', 'url'=>'http://ginatrapani.org',
'avatar'=>'avatara.jpg', 'gender'=>'', 'birthday'=>'', 'location'=>'San Diego', 'description'=>'Blogger', 'url'=>'http://ginatrapani.org',
'is_verified'=>1, 'is_protected'=>0, 'follower_count'=>5000, 'post_count'=>1000, 'joined'=>'2007-03-06 13:48:05',
'network'=>'twitter');
$user1 = new User($user_array, 'Test Update');
Expand All @@ -170,12 +178,12 @@ public function testUpdateUsers() {
$user_dao = DAOFactory::getDAO('UserDAO');

$user_array1 = array('id'=>2, 'user_id'=>'13', 'user_name'=>'ginatrapani', 'full_name'=>'Gina Trapani',
'avatar'=>'avatar.jpg', 'location'=>'NYC', 'description'=>'Blogger', 'url'=>'http://ginatrapani.org',
'avatar'=>'avatar.jpg', 'gender'=>'', 'birthday'=>'', 'location'=>'NYC', 'description'=>'Blogger', 'url'=>'http://ginatrapani.org',
'is_verified'=>1, 'is_protected'=>0, 'follower_count'=>5000, 'post_count'=>1000,
'joined'=>'2007-03-06 13:48:05', 'network'=>'twitter', 'last_post_id'=>'abc123');
$user1 = new User($user_array1, 'Test');
$user_array2 = array('id'=>3, 'user_id'=>'14', 'user_name'=>'anildash', 'full_name'=>'Anil Dash',
'avatar'=>'avatar.jpg', 'location'=>'NYC', 'description'=>'Blogger', 'url'=>'http://ginatrapani.org',
'avatar'=>'avatar.jpg', 'gender'=>'', 'birthday'=>'', 'location'=>'NYC', 'description'=>'Blogger', 'url'=>'http://ginatrapani.org',
'is_verified'=>1, 'is_protected'=>0, 'follower_count'=>5000, 'post_count'=>1000,
'joined'=>'2007-03-06 13:48:05', 'network'=>'twitter', 'last_post_id'=>'abc456');
$user2 = new User($user_array2, 'Test');
Expand All @@ -196,6 +204,8 @@ public function testGetUserByNameUserExists() {
$this->assertEqual($user->user_id, 12);
$this->assertEqual($user->username, 'jack');
$this->assertEqual($user->full_name, 'Jack Dorsey');
$this->assertEqual($user->gender, '');
$this->assertEqual($user->birthday, '');
$this->assertEqual($user->location, 'San Francisco');
}

Expand Down Expand Up @@ -256,6 +266,8 @@ private function buildSearchData() {
'author_user_id' => '100',
'author_username' => 'ecucurella',
'author_fullname' => 'Eduard Cucurella',
'author_gender' => '',
'author_birthday' => '',
'author_avatar' => 'http://aa.com',
'author_follower_count' => 0,
'post_text' => '#Messi is the best http://flic.kr/p/ http://flic.kr/a/',
Expand Down Expand Up @@ -286,6 +298,8 @@ private function buildSearchData() {
'author_user_id' => '101',
'author_username' => 'vetcastellnou',
'author_fullname' => 'Veterans Castellnou',
'author_gender' => '',
'author_birthday' => '',
'author_avatar' => 'http://aa.com',
'author_follower_count' => 0,
'post_text' => 'Post without any hashtag http://flic.kr/p/',
Expand Down Expand Up @@ -316,6 +330,8 @@ private function buildSearchData() {
'author_user_id' => '102',
'author_username' => 'efectivament',
'author_fullname' => 'efectivament',
'author_gender' => '',
'author_birthday' => '',
'author_avatar' => 'http://aa.com',
'author_follower_count' => 0,
'post_text' => 'Post with #Messi hashtag http://flic.kr/p/',
Expand Down Expand Up @@ -346,6 +362,8 @@ private function buildSearchData() {
'author_user_id' => '102',
'author_username' => 'efectivament',
'author_fullname' => 'efectivament',
'author_gender' => '',
'author_birthday' => '',
'author_avatar' => 'http://aa.com',
'author_follower_count' => 0,
'post_text' => 'Post without any hashtag 2',
Expand Down
3 changes: 2 additions & 1 deletion webapp/_lib/class.Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,10 @@ public static function mailViaMandrill($to, $subject, $message) {
if (Utils::isTest()) {
self::setLastMail(json_encode($message));
} else {

$result = $mandrill->messages->send($message, $async, $ip_pool);
//DEBUG
//print_r($result);
print_r($result);
}
} catch (Mandrill_Error $e) {
throw new Exception('An error occurred while sending email via Mandrill. ' . get_class($e) .
Expand Down
Loading