Skip to content

Commit

Permalink
[DB MIGRATION REQ'D] Insights stream
Browse files Browse the repository at this point in the history
Display stream of generated insights from link in status bar

New pluggable Insights Generator plugin
* Create insight baseline model and DAOs that plugin populates
* Abstract all the insights logic into individual "plugin" PHP files
* Set up hooks for the Insight Generator plugin to dynamically call the individual insight plugin files

Bootstrapify insights feed, login/register, web crawl
  • Loading branch information
ginatrapani committed Aug 23, 2012
1 parent 63b4aa8 commit 2ef7324
Show file tree
Hide file tree
Showing 117 changed files with 11,280 additions and 475 deletions.
4 changes: 2 additions & 2 deletions extras/dev/makemodel/classes/class.ModelMaker.php
Expand Up @@ -3,7 +3,7 @@
*
* ThinkUp/extras/dev/makemodel/classes/class.ModelMaker.php
*
* Copyright (c) 2009-2010 Gina Trapani
* Copyright (c) 2011-2012 Gina Trapani
*
* LICENSE:
*
Expand All @@ -22,7 +22,7 @@
*
* @author Gina Trapani <ginatrapani[at]gmail[dot]com>
* @license http://www.gnu.org/licenses/gpl.html
* @copyright 2009-2010 Gina Trapani
* @copyright 2011-2012 Gina Trapani
*
* ModelMaker
*
Expand Down
4 changes: 2 additions & 2 deletions extras/dev/makemodel/makemodel.php
Expand Up @@ -3,7 +3,7 @@
*
* ThinkUp/extras/dev/makemodel/makemodel.php
*
* Copyright (c) 2009-2010 Gina Trapani
* Copyright (c) 2011-2012 Gina Trapani
*
* LICENSE:
*
Expand All @@ -22,7 +22,7 @@
*
* @author Gina Trapani <ginatrapani[at]gmail[dot]com>
* @license http://www.gnu.org/licenses/gpl.html
* @copyright 2009-2010 Gina Trapani
* @copyright 2011-2012 Gina Trapani
*
* Usage:
* makemode.php <table_name> <object_name> [<parent_object_name>]
Expand Down
25 changes: 25 additions & 0 deletions extras/dev/ramdisk/parse_config.php
@@ -1,4 +1,29 @@
<?php
/**
*
* ThinkUp/extras/dev/ramdisk/parse_config.php
*
* Copyright (c) 2009-2012 mwilkie
*
* LICENSE:
*
* This file is part of ThinkUp (http://thinkupapp.com).
*
* ThinkUp is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any
* later version.
*
* ThinkUp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with ThinkUp. If not, see
* <http://www.gnu.org/licenses/>.
*
* @author mwilkie <mark[at]bitterpill[dot]org>
* @license http://www.gnu.org/licenses/gpl.html
* @copyright 2009-2012 mwilkie
*/
require_once 'webapp/config.inc.php';

array_shift($argv);
Expand Down
25 changes: 25 additions & 0 deletions extras/scripts/getversion.php
@@ -1,4 +1,29 @@
<?php
/**
*
* ThinkUp/extras/scripts/getversion.php
*
* Copyright (c) 2009-2012 Gina Trapani
*
* LICENSE:
*
* This file is part of ThinkUp (http://thinkupapp.com).
*
* ThinkUp is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any
* later version.
*
* ThinkUp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with ThinkUp. If not, see
* <http://www.gnu.org/licenses/>.
*
* @author Gina Trapani <ginatrapani[at]gmail[dot]com>
* @license http://www.gnu.org/licenses/gpl.html
* @copyright 2009-2012 Gina Trapani
*/
chdir(dirname(dirname(dirname(__FILE__))));
require_once 'webapp/install/version.php';

Expand Down
18 changes: 9 additions & 9 deletions tests/TestOfAccountConfigurationController.php
Expand Up @@ -349,7 +349,7 @@ public function testAuthControlLoggedInNotAdmin() {
//test if view variables were set correctly
$v_mgr = $controller->getViewManager();
$this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 7);
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 8);

$owner = $v_mgr->getTemplateDataItem('owner');
$this->assertIsA($owner, 'Owner');
Expand All @@ -372,7 +372,7 @@ public function testAuthControlLoggedInAdmin() {
//test if view variables were set correctly
$v_mgr = $controller->getViewManager();
$this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 7);
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 8);

$owner = $v_mgr->getTemplateDataItem('owner');
$this->assertIsA($owner, 'Owner');
Expand Down Expand Up @@ -463,7 +463,7 @@ public function testAuthControlLoggedInChangePasswordSuccess() {
//test if view variables were set correctly
$v_mgr = $controller->getViewManager();
$this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 7);
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 8);

$owner = $v_mgr->getTemplateDataItem('owner');
$this->assertIsA($owner, 'Owner');
Expand Down Expand Up @@ -498,7 +498,7 @@ public function testAuthControlLoggedInChangePasswordOldPwdDoesntMatch() {
//test if view variables were set correctly
$v_mgr = $controller->getViewManager();
$this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 7);
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 8);

$owner = $v_mgr->getTemplateDataItem('owner');
$this->assertIsA($owner, 'Owner');
Expand Down Expand Up @@ -527,7 +527,7 @@ public function testAuthControlLoggedInChangePasswordOldPwdEmpty() {
//test if view variables were set correctly
$v_mgr = $controller->getViewManager();
$this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 7);
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 8);

$owner = $v_mgr->getTemplateDataItem('owner');
$this->assertIsA($owner, 'Owner');
Expand Down Expand Up @@ -556,7 +556,7 @@ public function testAuthControlLoggedInChangePasswordNewPwdsDontMatch() {
//test if view variables were set correctly
$v_mgr = $controller->getViewManager();
$this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 7);
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 8);

$owner = $v_mgr->getTemplateDataItem('owner');
$this->assertIsA($owner, 'Owner');
Expand Down Expand Up @@ -586,7 +586,7 @@ public function testAuthControlLoggedInChangePasswordNewPwdTooShort() {
//test if view variables were set correctly
$v_mgr = $controller->getViewManager();
$this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 7);
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 8);

$owner = $v_mgr->getTemplateDataItem('owner');
$this->assertIsA($owner, 'Owner');
Expand Down Expand Up @@ -617,7 +617,7 @@ public function testAuthControlLoggedInChangePasswordNewPwdNotAlphanumeric() {
//test if view variables were set correctly
$v_mgr = $controller->getViewManager();
$this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 7);
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 8);

$owner = $v_mgr->getTemplateDataItem('owner');
$this->assertIsA($owner, 'Owner');
Expand Down Expand Up @@ -698,7 +698,7 @@ public function testResetAPIKey() {
//test if view variables were set correctly
$v_mgr = $controller->getViewManager();
$this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 7);
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 8);

$owner = $v_mgr->getTemplateDataItem('owner');
$this->assertIsA($owner, 'Owner');
Expand Down
8 changes: 7 additions & 1 deletion tests/TestOfDAOFactory.php
Expand Up @@ -376,6 +376,12 @@ public function testGetShortLinkDAO() {
$this->assertIsA($dao, 'ShortLinkMySQLDAO');
}

public function testInsightBaselineDAO() {
$dao = DAOFactory::getDAO('InsightBaselineDAO');
$this->assertNotNull($dao);
$this->assertIsA($dao, 'InsightBaselineMySQLDAO');
}

public function testInsightDAO() {
$dao = DAOFactory::getDAO('InsightDAO');
$this->assertNotNull($dao);
Expand All @@ -393,7 +399,7 @@ public function testGetInstallerDAONoConfigFile(){
$this->assertTrue(isset($dao));
$this->assertIsA($dao, 'InstallerMySQLDAO');
$result = $dao->getTables();
$this->assertEqual(sizeof($result), 30);
$this->assertEqual(sizeof($result), 31);
$this->assertEqual($result[0], $cfg_values["table_prefix"].'encoded_locations');
$this->restoreConfigFile();
}
Expand Down
91 changes: 83 additions & 8 deletions tests/TestOfFavoritePostMySQLDAO.php
Expand Up @@ -101,10 +101,10 @@ protected function buildData() {
}
$is_protected = $counter == 18 ? 1 : 0; // post with id 18 is protected
$builders[] = FixtureBuilder::build('posts', array('post_id'=>$counter, 'author_user_id'=>13,
'author_username'=>'ev', 'author_fullname'=>'Ev Williams', 'author_avatar'=>'avatar.jpg',
'author_username'=>'ev', 'author_fullname'=>'Ev Williams', 'author_avatar'=>'avatar.jpg',
'post_text'=>'This is post '.$counter, 'source'=>$source, 'pub_date'=>'2006-01-01 00:'.
$pseudo_minute.':00', 'reply_count_cache'=>rand(0, 4), 'retweet_count_cache'=>5, 'network'=>'twitter',
'in_reply_to_post_id'=>null, 'in_retweet_of_post_id'=>null, 'is_geo_encoded'=>0,
'in_reply_to_post_id'=>null, 'in_retweet_of_post_id'=>null, 'is_geo_encoded'=>0,
'is_protected' => $is_protected));
$counter++;
}
Expand All @@ -122,17 +122,17 @@ protected function buildData() {
'is_protected' => $is_protected));

$builders[] = FixtureBuilder::build('links', array('url'=>'http://example.com/'.$counter,
'explanded_url'=>'http://example.com/'.$counter.'.html', 'title'=>'Link $counter', 'clicks'=>0,
'explanded_url'=>'http://example.com/'.$counter.'.html', 'title'=>'Link $counter', 'clicks'=>0,
'post_id'=>$post_id, 'image_src'=>''));

$counter++;
}

$builders[] = FixtureBuilder::build('posts', array('post_id'=>10822735852740608, 'author_user_id'=>23,
'author_username'=>'user3', 'author_fullname'=>'User 3', 'network'=>'twitter',
'author_username'=>'user3', 'author_fullname'=>'User 3', 'network'=>'twitter',
'post_text'=>'@nytimes has posted an interactive panoramic photo that shows how Times Square has changed over'.
' the last 20 years http://nyti.ms/hmTVzP',
'source'=>'web', 'pub_date'=>'-300s', 'reply_count_cache'=>0, 'retweet_count_cache'=>0,
' the last 20 years http://nyti.ms/hmTVzP',
'source'=>'web', 'pub_date'=>'-300s', 'reply_count_cache'=>0, 'retweet_count_cache'=>0,
'location'=>'New York City', 'is_geo_encoded'=>0, 'is_protected' => 0));

// have 'user1' favorite some of ev's posts
Expand Down Expand Up @@ -337,12 +337,87 @@ public function testGetFavdsOfPost() {
$this->assertEqual(count($res), 2);
}

public function testGetFavoritesFromOneYearAgo() {
//build post published one year ago today
$builders[] = FixtureBuilder::build('posts', array('post_id'=>'abadadfd1212', 'author_user_id'=>'19',
'author_username'=>'linkbaiter', 'author_fullname'=>'Link Baiter', 'is_geo_encoded'=>0,
'post_text'=>'This is link post '.$counter, 'source'=>'web', 'pub_date'=>'-366d',
'reply_count_cache'=>0, 'retweet_count_cache'=>0, 'network'=>'twitter',
'is_protected' => 0));

//build favorite of that post by test user ev
$builders[] = FixtureBuilder::build('favorites', array('post_id'=>'abadadfd1212', 'author_user_id'=>'19',
'fav_of_user_id'=>'13', 'network'=>'twitter'));

//get favorites from one year ago today
$result = $this->dao->getFavoritesFromOneYearAgo('13', 'twitter');

//assert post is returned
$this->assertEqual(sizeof($result), 1);
$this->assertEqual($result[0]->post_id, 'abadadfd1212');

//build post published one year and 4 days ago today
$builders[] = FixtureBuilder::build('posts', array('post_id'=>'abadadfd1213', 'author_user_id'=>'19',
'author_username'=>'linkbaiter', 'author_fullname'=>'Link Baiter', 'is_geo_encoded'=>0,
'post_text'=>'This is link post '.$counter, 'source'=>'web', 'pub_date'=>'-370d',
'reply_count_cache'=>0, 'retweet_count_cache'=>0, 'network'=>'twitter',
'is_protected' => 0));

//build favorite of that post by test user ev
$builders[] = FixtureBuilder::build('favorites', array('post_id'=>'abadadfd1213', 'author_user_id'=>'19',
'fav_of_user_id'=>'13', 'network'=>'twitter'));

$since_date = date("Y-m-d", strtotime("-4 day"));
//get favorites from one year ago today
$result = $this->dao->getFavoritesFromOneYearAgo('13', 'twitter', $since_date);

//assert post is returned
$this->assertEqual(sizeof($result), 1);
$this->assertEqual($result[0]->post_id, 'abadadfd1213');
}

public function testGetUsersWhoFavoritedMostOfYourPosts() {
//build post published 3 days ago
$builders[] = FixtureBuilder::build('posts', array('post_id'=>'abadadfd1212', 'author_user_id'=>'19',
'author_username'=>'linkbaiter', 'author_fullname'=>'Link Baiter', 'is_geo_encoded'=>0,
'post_text'=>'This is link post '.$counter, 'source'=>'web', 'pub_date'=>'-3d',
'reply_count_cache'=>0, 'retweet_count_cache'=>0, 'network'=>'twitter',
'is_protected' => 0));

//build post published 4 days ago
$builders[] = FixtureBuilder::build('posts', array('post_id'=>'abadadfd1213', 'author_user_id'=>'19',
'author_username'=>'linkbaiter', 'author_fullname'=>'Link Baiter', 'is_geo_encoded'=>0,
'post_text'=>'This is link post '.$counter, 'source'=>'web', 'pub_date'=>'-4d',
'reply_count_cache'=>0, 'retweet_count_cache'=>0, 'network'=>'twitter',
'is_protected' => 0));

//build favorite of those posts by test user ev
$builders[] = FixtureBuilder::build('favorites', array('post_id'=>'abadadfd1212', 'author_user_id'=>'19',
'fav_of_user_id'=>'13', 'network'=>'twitter'));

$builders[] = FixtureBuilder::build('favorites', array('post_id'=>'abadadfd1213', 'author_user_id'=>'19',
'fav_of_user_id'=>'13', 'network'=>'twitter'));

//build favorite of that post by test user user1
$builders[] = FixtureBuilder::build('favorites', array('post_id'=>'abadadfd1212', 'author_user_id'=>'19',
'fav_of_user_id'=>'20', 'network'=>'twitter'));

//build favorite of that post by test user user2
$builders[] = FixtureBuilder::build('favorites', array('post_id'=>'abadadfd1212', 'author_user_id'=>'19',
'fav_of_user_id'=>'21', 'network'=>'twitter'));

$result = $this->dao->getUsersWhoFavoritedMostOfYourPosts('19', 'twitter', 7);
$this->debug(Utils::varDumpToString($result));
$this->assertEqual(sizeof($result), 1);
$this->assertEqual($result[0]->username, 'ev');
}

/**
* helper method to build a post
*/
private function buildPostArray1() {
$vals = array();
$vals['post_id']=2904;
$vals['post_id']='2904';
$vals['author_username']='quoter';
$vals['author_fullname']="Quoter of Quotables";
$vals['author_avatar']='avatar.jpg';
Expand All @@ -360,7 +435,7 @@ private function buildPostArray1() {
*/
private function buildPostArray2() {
$vals = array();
$vals['post_id']=10822735852740608;
$vals['post_id']='10822735852740608';
$vals['author_username']='user3';
$vals['author_fullname']="User 3";
$vals['author_avatar']='avatar.jpg';
Expand Down

0 comments on commit 2ef7324

Please sign in to comment.