public function testGetPostActivityVisualizationData()
 {
     $hot_posts = array((object) array('post_text' => 'First Û Post', 'favlike_count_cache' => 1, 'all_retweets' => 2, 'reply_count_cache' => 3), (object) array('post_text' => 'Second Post', 'favlike_count_cache' => 10, 'all_retweets' => 20, 'reply_count_cache' => 30));
     $result = ChartHelper::getPostActivityVisualizationData($hot_posts, 'twitter');
     $this->assertEqual(gettype($result), 'string');
     $visualization_object = json_decode($result);
     $this->assertEqual(sizeof($visualization_object->rows), 2);
     $this->assertEqual(sizeof($visualization_object->cols), 4);
     $this->assertEqual($visualization_object->cols[0]->label, 'Tweet');
     $this->assertEqual($visualization_object->cols[1]->label, 'Replies');
     $this->assertEqual($visualization_object->cols[2]->label, 'Retweets');
     $this->assertEqual($visualization_object->cols[3]->label, 'Favorites');
     //Different PHP versions handle this differently
     if (version_compare(phpversion(), '5.4', '<')) {
         $this->assertEqual($visualization_object->rows[0]->c[0]->v, 'First  Post...');
     } else {
         $this->assertEqual($visualization_object->rows[0]->c[0]->v, 'First ? Post...');
     }
     $this->assertEqual($visualization_object->rows[0]->c[1]->v, 3);
     $this->assertEqual($visualization_object->rows[0]->c[2]->v, 2);
     $this->assertEqual($visualization_object->rows[0]->c[3]->v, 1);
     $result = ChartHelper::getPostActivityVisualizationData($hot_posts, 'facebook');
     $this->assertEqual(gettype($result), 'string');
     $visualization_object = json_decode($result);
     $this->assertEqual(sizeof($visualization_object->rows), 2);
     $this->assertEqual(sizeof($visualization_object->cols), 4);
     $this->assertEqual($visualization_object->cols[0]->label, 'Post');
     $this->assertEqual($visualization_object->cols[1]->label, 'Comments');
     $this->assertEqual($visualization_object->cols[2]->label, 'Shares');
     $this->assertEqual($visualization_object->cols[3]->label, 'Likes');
     $this->assertEqual($visualization_object->rows[1]->c[0]->v, 'Second Post...');
     $this->assertEqual($visualization_object->rows[1]->c[1]->v, 30);
     $this->assertEqual($visualization_object->rows[1]->c[2]->v, 20);
     $this->assertEqual($visualization_object->rows[1]->c[3]->v, 10);
 }
 /**
  * Returns the data needed to display a New Users chart.
  *
  * @return void
  */
 public function actionGetNewUsersData()
 {
     $userGroupId = craft()->request->getRequiredPost('userGroupId');
     $startDateParam = craft()->request->getRequiredPost('startDate');
     $endDateParam = craft()->request->getRequiredPost('endDate');
     $startDate = DateTime::createFromString($startDateParam, craft()->timezone);
     $endDate = DateTime::createFromString($endDateParam, craft()->timezone);
     $endDate->modify('+1 day');
     $intervalUnit = 'day';
     // Prep the query
     $query = craft()->db->createCommand()->from('users users')->select('COUNT(*) as value');
     if ($userGroupId) {
         $query->join('usergroups_users userGroupUsers', 'userGroupUsers.userId = users.id');
         $query->where('userGroupUsers.groupId = :userGroupId', array(':userGroupId' => $userGroupId));
     }
     // Get the chart data table
     $dataTable = ChartHelper::getRunChartDataFromQuery($query, $startDate, $endDate, 'users.dateCreated', array('intervalUnit' => $intervalUnit, 'valueLabel' => Craft::t('New Users')));
     // Get the total number of new users
     $total = 0;
     foreach ($dataTable['rows'] as $row) {
         $total = $total + $row[1];
     }
     // Return everything
     $this->returnJson(array('dataTable' => $dataTable, 'total' => $total, 'formats' => ChartHelper::getFormats(), 'orientation' => craft()->locale->getOrientation(), 'scale' => $intervalUnit));
 }
Example #3
0
 /**
  * Get pie chart json for category-pie chart
  * 
  * @return string
  */
 protected function getCategoryPieJson()
 {
     $stats = $this->getModel()->getCategoryPieStats();
     $series = array();
     $trTable = Category_DBTable::DB_TABLE_NAME;
     foreach ($stats as $key => $value) {
         $series[] = array($this->translationMap[$trTable][$value['category']], (int) $value['count']);
     }
     $config = array('main_title' => self::CATEGORY_PIE_PLOT, 'series_name' => 'Contribution');
     return $this->chartHelper->getPieChartJson($config, $series);
 }
 /**
  * @inheritDoc IWidget::getBodyHtml()
  *
  * @return string|false
  */
 public function getBodyHtml()
 {
     if (craft()->getEdition() != Craft::Pro) {
         return false;
     }
     $settings = $this->getSettings();
     $groupId = $settings->userGroupId;
     $userGroup = craft()->userGroups->getGroupById($groupId);
     $options = $settings->getAttributes();
     $options['orientation'] = craft()->locale->getOrientation();
     craft()->templates->includeJsResource('js/NewUsersWidget.js');
     craft()->templates->includeJs('new Craft.NewUsersWidget(' . $this->model->id . ', ' . JsonHelper::encode($options) . ');');
     $dateRange = false;
     $dateRanges = ChartHelper::getDateRanges();
     if (isset($dateRanges[$settings->dateRange])) {
         $dateRange = $dateRanges[$settings->dateRange];
     }
     return '<div></div>';
 }
 /**
  * Returns the data needed to display a stats chart.
  */
 public function actionGetStatsData()
 {
     $statHandle = craft()->request->getRequiredPost('statHandle');
     $startDateParam = craft()->request->getRequiredPost('startDate');
     $endDateParam = craft()->request->getRequiredPost('endDate');
     $stat = craft()->elementStats_stats->getStatByHandle($statHandle);
     if (!$stat) {
         $this->returnErrorJson(Craft::t('Could not find the selected stat.'));
     }
     if (!$stat->elementType || !$stat->dateColumn) {
         $this->returnErrorJson(Craft::t('The stat does not support chart view.'));
     }
     // Prep the query
     try {
         $criteria = $stat->getCriteria();
     } catch (\Exception $e) {
         ElementStatsPlugin::log('There was an error while generating the stats. ' . $e->getMessage(), LogLevel::Error);
         $this->returnErrorJson(Craft::t('There was an error while generating the stats.'));
     }
     $query = craft()->elements->buildElementsQuery($criteria);
     $query->select('COUNT(*) as value');
     // Query debugging
     // ElementStatsPlugin::log(print_r($query->getText(), true), LogLevel::Info, true);
     // Prep the dates
     $startDate = DateTime::createFromString($startDateParam, craft()->timezone);
     $endDate = DateTime::createFromString($endDateParam, craft()->timezone);
     $endDate->modify('+1 day');
     $intervalUnit = 'day';
     // Get the chart data table
     $dataTable = ChartHelper::getRunChartDataFromQuery($query, $startDate, $endDate, $stat->dateColumn, ['intervalUnit' => $intervalUnit, 'valueLabel' => Craft::t('Value')]);
     // Get the total number of elements
     $total = 0;
     foreach ($dataTable['rows'] as $row) {
         $total = $total + $row[1];
     }
     // Return everything
     $this->returnJson(['dataTable' => $dataTable, 'total' => $total, 'formats' => ChartHelper::getFormats(), 'orientation' => craft()->locale->getOrientation(), 'scale' => $intervalUnit]);
 }
Example #6
0
 public function generateInsight(Instance $instance, User $user, $last_week_of_posts, $number_days)
 {
     parent::generateInsight($instance, $user, $last_week_of_posts, $number_days);
     $this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
     if ($instance->network == 'twitter') {
         $day_of_week = 3;
     } elseif ($instance->network == 'instagram') {
         $day_of_week = 5;
     } else {
         $day_of_week = 0;
     }
     $should_generate_insight = self::shouldGenerateWeeklyInsight('weekly_graph', $instance, $insight_date = 'today', $regenerate_existing_insight = false, $day_of_week = $day_of_week, count($last_week_of_posts));
     if ($should_generate_insight) {
         $most_popular_post = null;
         $best_popularity_params = array('index' => 0, 'reply' => 0, 'retweet' => 0, 'like' => 0);
         $total_replies = 0;
         $total_retweets = 0;
         $total_likes = 0;
         $engaged_posts = array();
         //Load photos for Instagram to display whether or not it was a video
         if ($instance->network == 'instagram') {
             $photo_dao = DAOFactory::getDAO('PhotoDAO');
             $last_week_of_posts_with_photos = array();
             foreach ($last_week_of_posts as $post) {
                 $post = $photo_dao->getPhoto($post->post_id, 'instagram');
                 $last_week_of_posts_with_photos[] = $post;
             }
             $last_week_of_posts = $last_week_of_posts_with_photos;
         }
         foreach ($last_week_of_posts as $post) {
             $reply_count = $post->reply_count_cache;
             $retweet_count = $post->retweet_count_cache;
             $fav_count = $post->favlike_count_cache;
             $total_replies += $reply_count;
             $total_retweets += $retweet_count;
             $total_likes += $fav_count;
             if ($instance->network !== 'instagram') {
                 $popularity_index = 5 * $reply_count + 3 * $retweet_count + 2 * $fav_count;
             } else {
                 $popularity_index = 3 * $reply_count + 0 * $retweet_count + 5 * $fav_count;
             }
             if ($popularity_index > $best_popularity_params['index']) {
                 $best_popularity_params['index'] = $popularity_index;
                 $best_popularity_params['reply'] = $reply_count;
                 if ($instance->network !== 'instagram') {
                     $best_popularity_params['retweet'] = $retweet_count;
                 }
                 $best_popularity_params['like'] = $fav_count;
                 $most_popular_post = $post;
             }
             if ($popularity_index > 0) {
                 $post->popularity_index = $popularity_index;
                 $engaged_posts[] = $post;
             }
         }
         if (isset($most_popular_post)) {
             usort($engaged_posts, array($this, 'compareEngagedPosts'));
             $posts = array_slice($engaged_posts, 0, 10);
             if ($total_replies >= $total_likes && $total_replies >= $total_retweets) {
                 $insight_headline = $this->username . " really inspired conversations";
                 $lower = array();
                 if ($total_replies > $total_likes) {
                     $lower[] = $this->terms->getNoun('like', InsightTerms::PLURAL);
                 }
                 if ($total_replies > $total_retweets) {
                     $lower[] = $this->terms->getNoun('retweet', InsightTerms::PLURAL);
                 }
                 if (count($lower) == 0) {
                     $insight_text = $this->username . ' got more ' . $this->terms->getNoun('reply', InsightTerms::PLURAL) . " than anything else.";
                 } else {
                     $insight_text = 'In the past week, ' . $this->terms->getNoun('reply', InsightTerms::PLURAL) . ' to ' . $this->username . ' outnumbered ' . join(' or ', $lower) . '.';
                 }
             } else {
                 if ($total_likes >= $total_replies && $total_likes >= $total_retweets) {
                     if ($instance->network !== 'instagram') {
                         $insight_headline = "Whatever " . $this->username . " said must have been memorable";
                     } else {
                         $insight_headline = $this->username . " really won hearts";
                     }
                     $insight_text = 'In the past week, ' . $this->username . ' got ' . number_format($total_likes) . ' ' . $this->terms->getNoun('like', $total_likes == 1 ? InsightTerms::SINGULAR : InsightTerms::PLURAL);
                     $lower = array();
                     if ($total_likes > $total_replies && $total_replies > 0) {
                         $plural = $total_replies == 1 ? InsightTerms::SINGULAR : InsightTerms::PLURAL;
                         $lower[] = number_format($total_replies) . ' ' . $this->terms->getNoun('reply', $plural);
                     }
                     if ($total_likes > $total_retweets && $total_retweets > 0) {
                         $plural = $total_retweets == 1 ? InsightTerms::SINGULAR : InsightTerms::PLURAL;
                         $lower[] = number_format($total_retweets) . ' ' . $this->terms->getNoun('retweet', $plural);
                     }
                     if (count($lower) == 0) {
                         $insight_text .= '.';
                     } else {
                         $insight_text .= ', beating out ' . join(' and ', $lower) . '.';
                     }
                 } else {
                     $insight_headline = $this->username . " shared lots of things people wanted to amplify";
                     $lower = array();
                     if ($total_retweets > $total_replies) {
                         $lower[] = $this->terms->getNoun('reply', InsightTerms::PLURAL) . ' by ' . number_format($total_retweets - $total_replies);
                     }
                     if ($total_retweets > $total_likes) {
                         $lower[] = $this->terms->getNoun('like', InsightTerms::PLURAL) . ' by ' . number_format($total_retweets - $total_likes);
                     }
                     if (count($lower) > 0) {
                         $insight_text = 'This past week, ' . $this->username . "'s " . $this->terms->getNoun('retweet', InsightTerms::PLURAL) . ' outnumbered ' . join(' and ', $lower) . '.';
                     }
                 }
             }
             //Only show this insight if there's a chart with more than 3 posts on it
             if (count($posts) > 3) {
                 $my_insight = new Insight();
                 $my_insight->slug = 'weekly_graph';
                 $my_insight->instance_id = $instance->id;
                 $my_insight->date = $this->insight_date;
                 $my_insight->headline = $insight_headline;
                 $my_insight->text = $insight_text;
                 $my_insight->header_image = $user->avatar;
                 $my_insight->filename = basename(__FILE__, ".php");
                 $my_insight->emphasis = Insight::EMPHASIS_MED;
                 $formatted_posts = array(ChartHelper::getPostActivityVisualizationData($posts, $instance->network));
                 $my_insight->setPosts($formatted_posts);
                 $this->insight_dao->insertInsight($my_insight);
             } else {
                 $this->logger->logInfo("Not enough posts to display chart", __METHOD__ . ',' . __LINE__);
             }
         }
     }
     $this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
 }
Example #7
0
             $arr = DBHelper::selectRows(TBL_REPORTS, null, null, REPORT_PACKAGE_NAME . ',COUNT(*)', REPORT_PACKAGE_NAME, null, false);
             if ($arr != null) {
                 for ($i = 0; $i < sizeof($arr); ++$i) {
                     $arr[$i][0] = ReportHelper::formatPackageName($arr[$i][0], true);
                 }
                 $data = ChartHelper::convertMySQLArrToPieChartJSON($arr);
             } else {
                 $message = 'No data yet recorded.|';
             }
             break;
         case REPORTS_EVOLUTION_LINE_CHART_ID:
             $projection = 'DATE(NOW()-INTERVAL ' . INC_VALUE . ' DAY) date, ' . 'DATE_FORMAT(DATE(NOW()-INTERVAL ' . INC_VALUE . ' DAY),"%m-%d") formatted_date, ' . '(SELECT COUNT(*) FROM ' . TBL_REPORTS . ' WHERE DATE(user_crash_date)=date) reports,' . '(SELECT COUNT(*) FROM ' . TBL_ISSUES . ' WHERE DATE(issue_datetime)=date) issues, ' . '(SELECT count(*)/DAYOFYEAR(DATE_FORMAT(' . REPORT_CRASH_DATE . ', "%Y-%m-%d")) FROM ' . TBL_REPORTS . ' WHERE DATE_FORMAT(' . REPORT_CRASH_DATE . ',"%Y")=\'' . date('Y') . '\') avg_per_day_current_year';
             $orderby = 'inc ASC LIMIT 15';
             $arr = DBHelper::selectRows(TBL_INCREMENTS, null, $orderby, $projection, null, null, true);
             if ($arr != null && count($arr) > 0) {
                 $data = ChartHelper::convertMySQLArrToReportsEvolChartJSON($arr);
             } else {
                 $message = 'No data yet recorded.|';
             }
             break;
         default:
             $message = 'Unhandled chart id requested !!!';
     }
     echo $message . '|' . $data;
     break;
     //////// CLEAR LOGS
 //////// CLEAR LOGS
 case 'clearlogs':
     if (strcmp($_POST['tab'], 'tabFile') == 0) {
         $mDebug = new Debug();
         $mDebug->clearLogFile();
</button>
		<button class="btn btn-primary" type="button" onclick="
			document.id('filter_from_date').value='';	
			document.id('filter_to_date').value='';
			document.id('filter_range').value='0';
			this.form.submit();"
			><i class="icon-remove "></i>&nbsp;</button>
		
	</div>
	<div class="clearfix"></div>
	<div class="row-fluid fltlft" id="statistic_chart" style="margin-top:10px;" align="left">
		<div id="error_notice"></div>
		<div class="clearfix"></div>
		<div id="month_chart">
			<?php 
$chart = new ChartHelper(1, $chartState->chartType, 'height:440');
echo $chart->getRevenueChart($chartState->range, $chartState->fromDate, $chartState->toDate);
?>
		</div>
		
		
		<div id="draw_chart" class="span12">
		
		</div>
		<div id="loading_chart" style="display:none">LOADING...</div>
	</div>
</div>

<input type="hidden" name="task" value=""/>

</form>
Example #9
0
	 			});
		</script>
		<?php 
}
?>
	</div>
	
	<!-- ////// SALES PER APPLICATION ////// -->
	<div class="span4 app-stat-box" >
		<h4>Sales per Application</h4>
		<div id="salesPerApp" style="width:400px; height:200px;" ></div>
		<?php 
$salesPerApp = DbHelper::selectRows(TBL_SALES . ' LEFT JOIN ' . TBL_APPLICATIONS . ' ON ' . APP_ID . '=' . SALE_APP_ID, null, SALE_ORDER_CHARGED_TIMESTAMP . ' ASC', APP_NAME . ', COUNT(*) count', SALE_APP_ID, null, false);
?>
		<script type="text/javascript" >$(function() { drawPieChart('#salesPerApp', <?php 
echo ChartHelper::convertMySQLArrToPieChartJSON($salesPerApp, false);
?>
, false); });</script>
	</div>
</div>
<div class="row" >
	<div id="salesEvolutionLegend" class="span4" style="" ></div>
</div>



<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="libs/flot/excanvas.min.js"></script><![endif]-->
<script language="javascript" type="text/javascript" src="libs/flot/jquery.flot.min.js"></script>
<script language="javascript" type="text/javascript" src="libs/flot/jquery.flot.pie.min.js"></script>
<script language="javascript" type="text/javascript" src="libs/flot/jquery.flot.time.min.js"></script>
<script language="javascript" type="text/javascript" src="libs/flot/jquery.flot.stack.min.js"></script>
Example #10
0
 	
	<a href='index.php?option=com_bookpro&view=orders' class="btn-primary btn pull-right">
		<?php 
echo JText::_('COM_BOOKPRO_MORE_BOOKING');
?>
	</a>
		
	<a  href="<?php 
echo JRoute::_('index.php?option=com_bookpro&view=bookpro&layout=default_chart');
?>
" class="btn-primary btn pull-right" style="margin-right: 5px;">
		<i class="icon-chart"></i>&nbsp;<?php 
echo JText::_('COM_BOOKPRO_STATISTIC');
?>
	</a>
</legend>
<?php 
AImporter::helper('chart');
$chart = new ChartHelper(1, 'LineChart', 'height:230,backgroundColor:"#F7F7F7",vAxis: {title: "Total ' . JComponentHelper::getParams('com_bookpro')->get('currency_symbol') . '"}');
echo $chart->getRevenueChart('lastmonth');
?>
</div>
<div class="span3">
		<?php 
echo $this->loadTemplate('config');
?>
</div>

</div>
</div>
 /**
  * Pre-fetch dashboard module data and store.
  */
 public function cacheDashboardModules()
 {
     $insight_dao = DAOFactory::getDAO('InsightDAO');
     $simplified_date = date('Y-m-d');
     //Cache FollowMySQLDAO::getLeastLikelyFollowersThisWeek
     $follow_dao = DAOFactory::getDAO('FollowDAO');
     $results = $follow_dao->getLeastLikelyFollowersThisWeek($this->instance->network_user_id, $this->instance->network, 13, 1);
     if (isset($results)) {
         //delete existing
         $insight_dao->deleteInsightsBySlug("FollowMySQLDAO::getLeastLikelyFollowersThisWeek", $this->instance->id);
         //insert new
         $insight_dao->insertInsightDeprecated("FollowMySQLDAO::getLeastLikelyFollowersThisWeek", $this->instance->id, $simplified_date, '', '', 'dashboard', Insight::EMPHASIS_LOW, serialize($results));
     }
     //Cache PostMySQLDAO::getHotPosts
     $post_dao = DAOFactory::getDAO('PostDAO');
     $hot_posts = $post_dao->getHotPosts($this->instance->network_user_id, $this->instance->network, 10);
     if (sizeof($hot_posts) > 3) {
         $hot_posts_data = ChartHelper::getPostActivityVisualizationData($hot_posts, $this->instance->network);
         //delete existing
         //TODO Go back to deleting this existing data once insights stream doesn't reference it
         //$insight_dao->deleteInsightsBySlug("PostMySQLDAO::getHotPosts", $this->instance->id);
         //insert new
         $insight_dao->insertInsightDeprecated("PostMySQLDAO::getHotPosts", $this->instance->id, $simplified_date, '', '', 'dashboard', Insight::EMPHASIS_LOW, serialize($hot_posts_data));
     }
     //Cache ShortLinkMySQLDAO::getRecentClickStats
     $short_link_dao = DAOFactory::getDAO('ShortLinkDAO');
     $click_stats = $short_link_dao->getRecentClickStats($this->instance, 10);
     if (sizeof($click_stats) > 3) {
         $click_stats_data = self::getClickStatsVisualizationData($click_stats);
         //delete existing
         //TODO Go back to deleting this existing data once insights stream doesn't reference it
         //$insight_dao->deleteInsightsBySlug("ShortLinkMySQLDAO::getRecentClickStats", $this->instance->id);
         //insert new
         $insight_dao->insertInsightDeprecated("ShortLinkMySQLDAO::getRecentClickStats", $this->instance->id, $simplified_date, '', '', 'dashboard', Insight::EMPHASIS_LOW, serialize($click_stats_data));
     }
     //Cache PostMySQLDAO::getAllPostsByUsernameOrderedBy // getMostRepliedToPostsInLastWeek
     $most_replied_to_1wk = $post_dao->getMostRepliedToPostsInLastWeek($this->instance->network_username, $this->instance->network, 5);
     if (sizeof($most_replied_to_1wk) > 1) {
         //delete existing
         $insight_dao->deleteInsightsBySlug("PostMySQLDAO::getMostRepliedToPostsInLastWeek", $this->instance->id);
         //insert new
         $insight_dao->insertInsightDeprecated("PostMySQLDAO::getMostRepliedToPostsInLastWeek", $this->instance->id, $simplified_date, '', '', 'dashboard', Insight::EMPHASIS_LOW, serialize($most_replied_to_1wk));
     }
     //Cache PostMySQLDAO::getAllPostsByUsernameOrderedBy // getMostRetweetedPostsInLastWeek
     $most_retweeted_1wk = $post_dao->getMostRetweetedPostsInLastWeek($this->instance->network_username, $this->instance->network, 5);
     if (sizeof($most_retweeted_1wk) > 1) {
         //delete existing
         $insight_dao->deleteInsightsBySlug("PostMySQLDAO::getMostRetweetedPostsInLastWeek", $this->instance->id);
         //insert new
         $insight_dao->insertInsightDeprecated("PostMySQLDAO::getMostRetweetedPostsInLastWeek", $this->instance->id, $simplified_date, '', '', 'dashboard', Insight::EMPHASIS_LOW, serialize($most_retweeted_1wk));
     }
     //Cache PostMySQLDAO::getClientsUsedByUserOnNetwork
     $clients_usage = $post_dao->getClientsUsedByUserOnNetwork($this->instance->network_user_id, $this->instance->network);
     //delete existing
     $insight_dao->deleteInsightsBySlug("PostMySQLDAO::getClientsUsedByUserOnNetwork", $this->instance->id);
     //insert new
     $insight_dao->insertInsightDeprecated("PostMySQLDAO::getClientsUsedByUserOnNetwork", $this->instance->id, $simplified_date, '', '', 'dashboard', Insight::EMPHASIS_LOW, serialize($clients_usage));
     //Cache PostMySQLDAO::getOnThisDayFlashbackPosts
     $posts_flashback = $post_dao->getOnThisDayFlashbackPosts($this->instance->network_user_id, $this->instance->network);
     //delete existing
     $insight_dao->deleteInsightsBySlug("PostMySQLDAO::getOnThisDayFlashbackPosts", $this->instance->id);
     //insert new
     $insight_dao->insertInsightDeprecated("PostMySQLDAO::getOnThisDayFlashbackPosts", $this->instance->id, $simplified_date, '', '', 'dashboard', Insight::EMPHASIS_LOW, serialize($posts_flashback));
     //if it's December or January, cache PostMySQLDAO::getMostPopularPostsOfTheYear
     if (date('n') == 12 || date('n') == 1) {
         if (date('n') == 12) {
             $year = date('Y');
         } else {
             $year = intval(date('Y')) - 1;
         }
         //Cache PostMySQLDAO::getMostPopularPostsOfTheYear
         $posts_yearly_popular = $post_dao->getMostPopularPostsOfTheYear($this->instance->network_user_id, $this->instance->network, $year, 5);
         //delete existing
         $insight_dao->deleteInsightsBySlug("PostMySQLDAO::getMostPopularPostsOfTheYear", $this->instance->id);
         //insert new
         $insight_dao->insertInsightDeprecated("PostMySQLDAO::getMostPopularPostsOfTheYear", $this->instance->id, $simplified_date, '', '', 'dashboard', Insight::EMPHASIS_LOW, serialize($posts_yearly_popular));
     }
     if ($this->instance->network == 'foursquare') {
         // Cache PostMySQLDAO::countCheckinsToPlaceTypesLastWeek
         $checkins_count = $post_dao->countCheckinsToPlaceTypesLastWeek($this->instance->network_user_id, $this->instance->network);
         //delete existing
         $insight_dao->deleteInsightsBySlug("PostMySQLDAO::countCheckinsToPlaceTypesLastWeek", $this->instance->id);
         //insert new
         $insight_dao->insertInsightDeprecated("PostMySQLDAO::countCheckinsToPlaceTypesLastWeek", $this->instance->id, $simplified_date, '', '', 'dashboard', Insight::EMPHASIS_LOW, serialize($checkins_count));
         // Cache PostMySQLDAO::countCheckinsToPlaceTypes
         $checkins_all_time_count = $post_dao->countCheckinsToPlaceTypes($this->instance->network_user_id, $this->instance->network);
         //delete existing
         $insight_dao->deleteInsightsBySlug("PostMySQLDAO::countCheckinsToPlaceTypes", $this->instance->id);
         //insert new
         $insight_dao->insertInsightDeprecated("PostMySQLDAO::countCheckinsToPlaceTypes", $this->instance->id, $simplified_date, '', '', 'dashboard', Insight::EMPHASIS_LOW, serialize($checkins_all_time_count));
         // Cache PostMySQLDAO::getPostsPerHourDataVis
         $hourly_checkin_datavis = $post_dao->getPostsPerHourDataVis($this->instance->network_user_id, $this->instance->network);
         //delete existing
         $insight_dao->deleteInsightsBySlug("PostMySQLDAO::getPostsPerHourDataVis", $this->instance->id);
         //insert new
         $insight_dao->insertInsightDeprecated("PostMySQLDAO::getPostsPerHourDataVis", $this->instance->id, $simplified_date, '', '', 'dashboard', Insight::EMPHASIS_LOW, serialize($hourly_checkin_datavis));
         // Cache PostMySQLDAO::getAllCheckinsInLastWeekAsGoogleMap
         $checkins_map = $post_dao->getAllCheckinsInLastWeekAsGoogleMap($this->instance->network_user_id, $this->instance->network);
         //delete existing
         $insight_dao->deleteInsightsBySlug("PostMySQLDAO::getAllCheckinsInLastWeekAsGoogleMap", $this->instance->id);
         //insert new
         $insight_dao->insertInsightDeprecated("PostMySQLDAO::getAllCheckinsInLastWeekAsGoogleMap", $this->instance->id, $simplified_date, '', '', 'dashboard', Insight::EMPHASIS_LOW, serialize($checkins_map));
     }
 }