Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
* Avoid array warning for dashboard clients usage
* Make sure testGetActiveInstancesStalestFirstForOwnerByNetworkNoAuthError result ordering is consistent, using differing crawler_last_run timestamps
  • Loading branch information
ginatrapani committed Jul 5, 2012
1 parent 8074e88 commit 258994c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion tests/TestOfInstanceMySQLDAO.php
Expand Up @@ -749,7 +749,7 @@ public function testUpdateInstanceUsername() {

public function testGetActiveInstancesStalestFirstForOwnerByNetworkNoAuthError() {
$this->builders[] = FixtureBuilder::build('instances', array('network_user_id'=>17, 'network_username'=>'yaya',
'network'=>'twitter', 'network_viewer_id'=>17, 'crawler_last_run'=>'2010-01-20 12:00:00', 'is_active'=>1,
'network'=>'twitter', 'network_viewer_id'=>17, 'crawler_last_run'=>'2010-01-21 12:00:00', 'is_active'=>1,
'is_public'=>0));

$this->builders[] = FixtureBuilder::build('owner_instances', array('owner_id'=>3, 'instance_id'=>6,
Expand Down
17 changes: 10 additions & 7 deletions webapp/_lib/controller/class.DashboardController.php
Expand Up @@ -267,15 +267,18 @@ private function loadDefaultDashboard() {
list($all_time_clients_usage, $latest_clients_usage) =
$insight_dao->getPreCachedInsightData(
'PostMySQLDAO::getClientsUsedByUserOnNetwork', $this->instance->id, date('Y-m-d'));
$this->addToView('most_replied_to_1wk', $most_replied_to_1wk);

// The sliceVisibilityThreshold option in the chart will prevent small slices from being created
$all_time_clients_usage = InsightsGenerator::getClientUsageVisualizationData($all_time_clients_usage);
$this->addToView('all_time_clients_usage', $all_time_clients_usage);
if (is_array($all_time_clients_usage)) {
// The sliceVisibilityThreshold option in the chart will prevent small slices from being created
$all_time_clients_usage = InsightsGenerator::getClientUsageVisualizationData($all_time_clients_usage);
$this->addToView('all_time_clients_usage', $all_time_clients_usage);
}

// Only show the two most used clients for the last 25 posts
$latest_clients_usage = array_slice($latest_clients_usage, 0, 2);
$this->addToView('latest_clients_usage', $latest_clients_usage);
if (is_array($latest_clients_usage) && sizeof($latest_clients_usage > 1)) {
// Only show the two most used clients for the last 25 posts
$latest_clients_usage = array_slice($latest_clients_usage, 0, 2);
$this->addToView('latest_clients_usage', $latest_clients_usage);
}
} else {
$this->addErrorMessage($username." on ".ucwords($this->instance->network).
" isn't set up on this ThinkUp installation.");
Expand Down
12 changes: 6 additions & 6 deletions webapp/_lib/model/class.InsightsGenerator.php
Expand Up @@ -116,8 +116,8 @@ public function generateInsights() {

/**
* Convert Hot Posts data to JSON for use with Google Charts
* @param array $hot_posts Array returned from PostDAO::getHotPosts
* @return string JSON
* @param arr $hot_posts Array returned from PostDAO::getHotPosts
* @return str JSON
*/
public static function getHotPostVisualizationData($hot_posts, $network) {
switch ($network) {
Expand Down Expand Up @@ -177,8 +177,8 @@ public static function getHotPostVisualizationData($hot_posts, $network) {

/**
* Convert click stats data to JSON for Google Charts
* @param array $click_stats Array returned from ShortLinkDAO::getRecentClickStats
* @return string JSON
* @param arr $click_stats Array returned from ShortLinkDAO::getRecentClickStats
* @return str JSON
*/
public static function getClickStatsVisualizationData($click_stats) {
$metadata = array(
Expand All @@ -198,8 +198,8 @@ public static function getClickStatsVisualizationData($click_stats) {

/**
* Convert client usage data to JSON for Google Charts
* @param array $client_usage Array returned from PostDAO::getClientsUsedByUserOnNetwork
* @return string JSON
* @param arr $client_usage Array returned from PostDAO::getClientsUsedByUserOnNetwork
* @return str JSON
*/
public static function getClientUsageVisualizationData($client_usage) {
$metadata = array(
Expand Down
4 changes: 3 additions & 1 deletion webapp/_lib/view/_dashboard.clientusage.tpl
@@ -1,3 +1,4 @@
{if $all_time_clients_usage}
<div class="omega">
<h2>Client Usage <span class="detail">(all posts)</span></h2>
<div class="article">
Expand Down Expand Up @@ -39,4 +40,5 @@
client_usage_chart.draw();
}
{/literal}
</script>
</script>
{/if}
13 changes: 6 additions & 7 deletions webapp/_lib/view/dashboard.tpl
Expand Up @@ -134,13 +134,12 @@
</div>
{/if}
{if $instance->network eq 'twitter' }
<div class="section" style="float : left; clear : none; width : 345px;">
{include file="_dashboard.posttypes.tpl"}
</div>

<div class="section" style="float : left; clear : none;margin-left : 10px; width : 345px;">
{include file="_dashboard.clientusage.tpl"}
</div>
<div class="section" style="float : left; clear : none; width : 345px;">
{include file="_dashboard.posttypes.tpl"}
</div>
<div class="section" style="float : left; clear : none;margin-left : 10px; width : 345px;">
{include file="_dashboard.clientusage.tpl"}
</div>
{/if}
{/if} {* end if $data_template *}
{/if}
Expand Down

0 comments on commit 258994c

Please sign in to comment.