本文整理汇总了PHP中InsightPluginParent类的典型用法代码示例。如果您正苦于以下问题:PHP InsightPluginParent类的具体用法?PHP InsightPluginParent怎么用?PHP InsightPluginParent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InsightPluginParent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateInsight
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__);
$year = date('Y');
$regenerate = false;
//testing
//$regenerate = true;
$should_generate_insight = self::shouldGenerateEndOfYearAnnualInsight($this->slug, $instance, $insight_date = "{$year}-{$this->run_date}", $regenerate, $day_of_year = $this->run_date);
if ($should_generate_insight) {
$this->logger->logInfo("Should generate", __METHOD__ . ',' . __LINE__);
$insight = new Insight();
$insight->instance_id = $instance->id;
$insight->slug = $this->slug;
$insight->date = "{$year}-{$this->run_date}";
$top_three_replied_to = $this->topThreeThisYear($instance);
foreach ($top_three_replied_to as $key => $post) {
$post->author_avatar = $user->avatar;
}
//Populate Instagram photos
if ($instance->network == 'instagram') {
$photo_dao = DAOFactory::getDAO('PhotoDAO');
$popular_photos = array();
foreach ($top_three_replied_to as $key => $post) {
$post = $photo_dao->getPhoto($post->post_id, 'instagram');
$popular_photos[] = $post;
}
$top_three_replied_to = $popular_photos;
}
$post_dao = DAOFactory::getDAO('PostDAO');
$earliest_pub_date = $post_dao->getEarliestCapturedPostPubDate($instance);
$qualified_year = "";
if (date('Y', strtotime($earliest_pub_date)) == date('Y')) {
if (date('n', strtotime($earliest_pub_date)) > 1) {
//not January
//Earliest post was this year; figure out what month we have data since this year
$since = date('F', strtotime($earliest_pub_date));
$qualified_year = " (at least since " . $since . ")";
}
}
$copy = array('twitter' => array('normal' => array('headline' => "%username's most replied-to tweets of %year", 'body' => "Come for the faves, stay for the mentions. " . "In %year, %username inspired the most conversation in " . "these tweets%qualified_year."), 'one' => array('headline' => "%username's most replied-to tweet of %year", 'body' => "Come for the faves, stay for the mentions. " . "In %year, %username inspired the most conversation in " . "this tweet%qualified_year."), 'none' => array('headline' => "Let's talk", 'body' => "%username didn't get any replies in %year" . $qualified_year . ", but that's " . "about to change. Give @thinkup a mention — we love to talk!")), 'facebook' => array('normal' => array('headline' => "%username's most commented-on status updates of %year", 'body' => "Some status updates are meant to " . "be trivial. Others sow the seeds of meaningful " . "conversation. In %year, %username received the most comments " . "on these status updates%qualified_year."), 'one' => array('headline' => "%username's most commented-on status update of %year", 'body' => "Some status updates are meant to " . "be trivial. Others sow the seeds of meaningful " . "conversation. In %year, %username received the most comments " . "on this status update%qualified_year."), 'none' => array('headline' => "No comment", 'body' => "Is this thing on? No one commented on %username's " . "status updates on Facebook in %year" . $qualified_year . ".")), 'instagram' => array('normal' => array('headline' => "%username's most commented-on Instagram posts of %year", 'body' => "There's lots of eye candy on Instagram, and not much conversation. " . "But some photos and videos are so good people can't help but respond. " . "In %year, %username received the most comments " . "on these Instagram posts%qualified_year."), 'one' => array('headline' => "%username's most commented-on Instagram of %year", 'body' => "There's lots of eye candy on Instagram, and not much conversation. " . "But some photos and videos are so good people can't help but respond. " . "In %year, %username received the most comments " . "on these Instagram posts%qualified_year."), 'none' => array('headline' => "No comment", 'body' => "Is this thing on? No one commented on %username's " . "Instagram photos and videos in %year" . $qualified_year . ".")));
$network = $instance->network;
if (sizeof($top_three_replied_to) > 1) {
$type = 'normal';
} else {
if (sizeof($top_three_replied_to) == 1) {
$type = 'one';
} else {
$type = 'none';
}
}
$insight->headline = $this->getVariableCopy(array($copy[$network][$type]['headline']), array('year' => $year));
$insight->text = $this->getVariableCopy(array($copy[$network][$type]['body']), array('year' => $year, 'qualified_year' => $qualified_year));
$insight->emphasis = Insight::EMPHASIS_HIGH;
$insight->filename = basename(__FILE__, ".php");
$insight->setPosts($top_three_replied_to);
$this->insight_dao->insertInsight($insight);
$this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
}
}
示例2: generateInsight
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__);
$video_dao = DAOFactory::getDAO('VideoDAO');
$filename = basename(__FILE__, ".php");
foreach ($last_week_of_posts as $post) {
if ($post->network == 'youtube') {
$video = $video_dao->getVideoByID($post->post_id, 'youtube');
$simplified_post_date = date('Y-m-d', strtotime($video->pub_date));
} else {
break;
}
// Get the average baselines
$total_likes_and_dislikes = $video->likes + $video->dislikes;
$percent_likes = round($video->likes / $total_likes_and_dislikes * 100, 2);
$percent_dislikes = round($video->dislikes / $total_likes_and_dislikes * 100, 2);
// If the video splits opinion in the range of 60/40 likes / dislikes or 40/60 likes / dislikes
if ($percent_likes >= 40 && $percent_likes <= 60) {
$headline = $video->post_text . " really touched a nerve!";
$insight_text = "{$percent_likes}" . "% of people liked ";
$insight_text .= "<a href=\"http://plus.google.com/{$instance->network_user_id}/about\">" . $instance->network_username;
$insight_text .= '</a>\'s video ';
$insight_text .= "<a href=\"http://www.youtube.com/watch?v={$post->post_id}\">" . $video->post_text . "</a> ";
$insight_text .= "and " . $percent_dislikes . "% disliked it.";
$this->insight_dao->insertInsightDeprecated("split_opinions" . $video->id, $instance->id, $simplified_post_date, $headline, $insight_text, $filename, 1, serialize($video));
}
}
}
示例3: generateInsight
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__);
$baseline_dao = DAOFactory::getDAO('InsightBaselineDAO');
foreach ($this->getSchedule() as $baseline_slug => $data) {
$now = TimeHelper::getTime();
if ($now >= strtotime($data['start']) && $now <= strtotime($data['end'])) {
$this->logger->logInfo("{$now} is in-schedule", __METHOD__ . ',' . __LINE__);
$baseline = $baseline_dao->getMostRecentInsightBaseline($baseline_slug, $instance->id);
if (!$baseline) {
if ($instance->network == 'facebook' && date('w') == 4 || $instance->network == 'twitter' && date('w') == 1 || Utils::isTest()) {
$found = $this->runInsightForConfig($data, $instance);
$baseline_dao->insertInsightBaseline($baseline_slug, $instance->id, $found);
} else {
$this->logger->logInfo("Not today", __METHOD__ . ',' . __LINE__);
}
} else {
$this->logger->logInfo("Already exists", __METHOD__ . ',' . __LINE__);
}
} else {
$this->logger->logInfo("Not in-schedule", __METHOD__ . ',' . __LINE__);
}
}
$this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
}
示例4: generateInsight
public function generateInsight(Instance $instance, $last_week_of_posts, $number_days)
{
parent::generateInsight($instance, $last_week_of_posts, $number_days);
$this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
if (self::shouldGenerateInsight('favorited_links', $instance, $insight_date = 'today', $regenerate_existing_insight = true)) {
$fpost_dao = DAOFactory::getDAO('FavoritePostDAO');
$favorited_posts = $fpost_dao->getAllFavoritePosts($instance->network_user_id, $instance->network, 40);
$todays_favorited_posts_with_links = array();
foreach ($favorited_posts as $post) {
if (date('Y-m-d', strtotime($post->pub_date)) == date('Y-m-d')) {
$post_text = $post->post_text;
$text_parser = new Twitter_Extractor($post_text);
$elements = $text_parser->extract();
if (count($elements['urls'])) {
$todays_favorited_posts_with_links[] = $post;
}
}
}
$favorited_links_count = count($todays_favorited_posts_with_links);
if ($favorited_links_count) {
$verb = '';
$post_type = '';
if ($favorited_links_count == 1) {
$insight_text = $this->username . " " . $this->terms->getVerb('liked') . " <strong>1 " . $this->terms->getNoun('post') . "</strong> with a link in it.";
} else {
$insight_text = $this->username . " " . $this->terms->getVerb('liked') . " <strong>" . $favorited_links_count . " " . $this->terms->getNoun('post', InsightTerms::PLURAL) . "</strong> with links in them:";
}
$this->insight_dao->insertInsightDeprecated("favorited_links", $instance->id, $this->insight_date, "Links you liked:", $insight_text, basename(__FILE__, ".php"), Insight::EMPHASIS_LOW, serialize($todays_favorited_posts_with_links));
}
}
$this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
}
示例5: generateInsight
public function generateInsight(Instance $instance, $last_week_of_posts, $number_days)
{
parent::generateInsight($instance, $last_week_of_posts, $number_days);
$this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
//Set up DAOs
$instance_hashtag_dao = DAOFactory::getDAO('InstanceHashtagDAO');
$hashtag_post_dao = DAOFactory::getDAO('HashtagPostDAO');
$hashtag_dao = DAOFactory::getDAO('HashtagDAO');
// Get all the hashtags for the instance
$instance_hashtags = $instance_hashtag_dao->getByInstance($instance->id);
// foreach hashtag, get the count of new posts
foreach ($instance_hashtags as $instance_hashtag) {
$total_new_posts = $hashtag_post_dao->getTotalPostsByHashtagAndDate($instance_hashtag->hashtag_id);
//Only insert insight if there are new results
if ($total_new_posts > 0) {
//Assemble insight text
$post_term = $instance->network == 'twitter' ? 'tweets' : 'posts';
$hashtag = $hashtag_dao->getHashtagByID($instance_hashtag->hashtag_id);
$link = 'search.php?u=' . $instance->network_username . '&n=' . $instance->network . '&c=searches&k=' . urlencode($hashtag->hashtag) . '&q=' . urlencode($hashtag->hashtag);
$text = number_format($total_new_posts) . " new " . $post_term . " contain <b><a href=\"" . $link . "\">" . $hashtag->hashtag . "</a></b>.";
// Insert insight
$this->insight_dao->insertInsightDeprecated("saved_search_results_" . $instance_hashtag->hashtag_id, $instance->id, $this->insight_date, "New search results:", $text, basename(__FILE__, ".php"), Insight::EMPHASIS_MED);
}
}
$this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
}
示例6: generateInsight
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 ($this->shouldGenerateInsight($this->slug, $instance, $insight_date = 'today', $regenerate = false)) {
$baseline_dao = DAOFactory::getDAO('InsightBaselineDAO');
$met_milestone = 0;
foreach ($this->milestones as $count => $text) {
if ($user->follower_count > $count && $user->follower_count < $count * 2) {
$met_milestone = $count;
} else {
if ($user->follower_count < $count) {
break;
}
}
}
if ($met_milestone) {
$baseline = $baseline_dao->getMostRecentInsightBaseline('follower_vis_last_run', $instance->id);
if (!isset($baseline->value) || isset($baseline->value) && $met_milestone > $baseline->value) {
$baseline_dao->insertInsightBaseline('follower_vis_last_run', $instance->id, $met_milestone);
$insight = new Insight();
$insight->slug = $this->slug;
$insight->instance_id = $instance->id;
$insight->date = $this->insight_date;
$insight->filename = basename(__FILE__, ".php");
$insight->emphasis = Insight::EMPHASIS_HIGH;
$insight->headline = $this->getVariableCopy(array($this->milestones[$met_milestone]['headline']), array('total' => number_format($user->follower_count)));
$insight->text = $this->getVariableCopy(array($this->milestones[$met_milestone]['text']), array('total' => number_format($user->follower_count), 'thres' => number_format($met_milestone)));
$insight->setHeroImage($this->milestones[$met_milestone]["hero_image"]);
$this->insight_dao->insertInsight($insight);
}
}
}
$this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
}
示例7: generateInsight
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__);
$network = $instance->network;
$user_id = $instance->network_user_id;
if ($network == 'twitter' && $this->shouldGenerateMonthlyInsight($this->slug, $instance, 'today', false, 8)) {
$my_count = $user->follower_count;
$follow_dao = DAOFactory::getDAO('FollowDAO');
$follow_count = $follow_dao->countTotalFriends($user_id, $network);
$median = $follow_dao->getMedianFollowerCountOfFriends($user_id, $network);
$number_under = $follow_dao->getCountOfFriendsWithFewerFollowers($user_id, $network, $my_count);
$rank = $follow_count - $number_under + 1;
$percentile = (int) sprintf('%d', 100 * ($number_under / $follow_count));
if ($percentile >= 50 && $my_count > $median) {
$insight = new Insight();
$insight->slug = $this->slug;
$insight->date = $this->insight_date;
$insight->instance_id = $instance->id;
$insight->filename = basename(__FILE__, ".php");
$insight->emphasis = Insight::EMPHASIS_MED;
$insight->headline = $this->getVariableCopy(array('%username has it good', 'A closer look at %username\'s follower count', '%username could lend a hand'));
$insight->text = $this->getVariableCopy(array("%username has more followers than %percentile% of the %total people %username follows. That means " . "<strong>%percentoftotal</strong> of %username's friends would reach a bigger audience " . "if %username retweeted them.", "%username has more followers than %percentile% of the people %username follows. That means " . "<strong>%percentoftotal</strong> of %username's friends would reach a bigger audience " . "if %username retweeted them."), array('total' => number_format($follow_count), 'percentoftotal' => number_format($number_under), 'percentile' => $percentile));
$this->insight_dao->insertInsight($insight);
}
}
$this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
}
示例8: generateInsight
public function generateInsight(Instance $instance, $last_week_of_posts, $number_days)
{
parent::generateInsight($instance, $last_week_of_posts, $number_days);
$this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
$since_date = date("Y-m-d");
$insight_date = new DateTime();
$insight_day_of_week = (int) $insight_date->format('w');
$insight_day_of_month = (int) $insight_date->format('j');
$filename = basename(__FILE__, ".php");
if ($insight_day_of_month == 1) {
//it's the first day of the month
// Past 30 days
if (self::shouldGenerateInsight('biggest_fans_last_30_days', $instance, $insight_date = $since_date)) {
$fav_dao = DAOFactory::getDAO('FavoritePostDAO');
$fans = $fav_dao->getUsersWhoFavoritedMostOfYourPosts($instance->network_user_id, $instance->network, 30);
if (isset($fans) && sizeof($fans) > 0) {
$this->insight_dao->insertInsightDeprecated("biggest_fans_last_30_days", $instance->id, $since_date, "Biggest fans:", "People who " . $this->terms->getVerb('liked') . " {$this->username}'s " . $this->terms->getNoun('post', InsightTerms::PLURAL) . " the most over the last 30 days: ", $filename, Insight::EMPHASIS_LOW, serialize($fans));
}
}
} else {
if ($insight_day_of_week == 0) {
//it's Sunday
// Past 7 days
if (self::shouldGenerateInsight('biggest_fans_last_7_days', $instance, $insight_date = $since_date)) {
$fav_dao = DAOFactory::getDAO('FavoritePostDAO');
$fans = $fav_dao->getUsersWhoFavoritedMostOfYourPosts($instance->network_user_id, $instance->network, 7);
if (isset($fans) && sizeof($fans) > 0) {
$this->insight_dao->insertInsightDeprecated("biggest_fans_last_7_days", $instance->id, $since_date, "Biggest fans:", "People who " . $this->terms->getVerb('liked') . " {$this->username}'s " . $this->terms->getNoun('post', InsightTerms::PLURAL) . " the most over the last 7 days: ", $filename, Insight::EMPHASIS_LOW, serialize($fans));
}
}
}
}
$this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
}
示例9: generateInsight
public function generateInsight(Instance $instance, $last_week_of_posts, $number_days)
{
parent::generateInsight($instance, $last_week_of_posts, $number_days);
$this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
$filename = basename(__FILE__, ".php");
foreach ($last_week_of_posts as $post) {
$simplified_post_date = date('Y-m-d', strtotime($post->pub_date));
// Map insight: If not a reply or retweet and geoencoded, show the map in the stream
if (!isset($post->in_reply_to_user_id) && !isset($post->in_reply_to_post_id) && !isset($post->in_retweet_of_post_id) && $post->reply_count_cache > 5) {
$plugin_option_dao = DAOFactory::GetDAO('PluginOptionDAO');
$options = $plugin_option_dao->getOptionsHash('geoencoder', true);
if (isset($options['gmaps_api_key']->option_value) && $post->is_geo_encoded == 1) {
//Get post's replies and loop through them to make sure at least 5 are indeed geoencoded
$post_dao = DAOFactory::getDAO('PostDAO');
$post_replies = $post_dao->getRepliesToPost($post->post_id, $post->network);
$total_geoencoded_replies = 0;
foreach ($post_replies as $reply) {
if ($reply->is_geo_encoded == 1) {
$total_geoencoded_replies++;
}
}
if ($total_geoencoded_replies > 4) {
$this->insight_dao->insertInsight('geoencoded_replies', $instance->id, $simplified_post_date, "Going global!", "{$this->username}'s post got responses from locations all over the map.", $filename, Insight::EMPHASIS_LOW, serialize($post));
}
}
}
}
$this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
}
示例10: generateInsight
public function generateInsight(Instance $instance, $last_week_of_posts, $number_days)
{
parent::generateInsight($instance, $last_week_of_posts, $number_days);
$this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
$filename = basename(__FILE__, ".php");
foreach ($last_week_of_posts as $post) {
//if post was a retweet, check if insight exists
if ($post->in_retweet_of_post_id != null && $post->in_rt_of_user_id != null) {
$simplified_post_date = date('Y-m-d', strtotime($post->pub_date));
//if insight doesn't exist fetch user details of original author and instance
if (self::shouldGenerateInsight('amplifier_' . $post->id, $instance, $insight_date = $simplified_post_date)) {
if (!isset($user_dao)) {
$user_dao = DAOFactory::getDAO('UserDAO');
}
if (!isset($instance_user)) {
$instance_user = $user_dao->getDetails($post->author_user_id, $post->network);
}
$retweeted_user = $user_dao->getDetails($post->in_rt_of_user_id, $post->network);
//if user exists and has fewer followers than instance user, build and insert insight
if (isset($retweeted_user) && $retweeted_user->follower_count < $instance_user->follower_count) {
$add_audience = number_format($instance_user->follower_count - $retweeted_user->follower_count);
$insight_text = "{$this->username} broadcast this post to <strong>{$add_audience}</strong> " . "more people than its author originally reached.";
$this->insight_dao->insertInsightDeprecated('amplifier_' . $post->id, $instance->id, $simplified_post_date, "Amplifier:", $insight_text, $filename, Insight::EMPHASIS_LOW, serialize($post));
}
}
}
}
$this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
}
示例11: generateInsight
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__);
$possible_messaging = array(array('headline' => 'Ohai', 'text' => 'Greetings, humans', 'header_image' => 'http://farm3.staticflickr.com/2713/4098259769_725b5fb65b_o.jpg'), array('headline' => 'Hello', 'text' => 'Greetings, earthlings', 'header_image' => 'http://farm9.staticflickr.com/8078/8276342554_5a51725f5f_n.jpg'), array('headline' => 'Yo', 'text' => 'Greetings, peeps', 'header_image' => 'http://farm6.staticflickr.com/5006/5367216303_83c5f2dc39_n.jpg'));
//Instantiate the Insight object
$my_insight = new Insight();
//REQUIRED: Set the insight's required attributes
//We pull some from the options above. But the could just be strings like 'Ohai'
$which_messaging = TimeHelper::getTime() % count($possible_messaging);
foreach ($possible_messaging[$which_messaging] as $field => $value) {
$my_insight->{$field} = $value;
}
$my_insight->slug = 'my_test_insight_hello_thinkup';
//slug to label this insight's content
$my_insight->instance_id = $instance->id;
$my_insight->date = $this->insight_date;
//date is often this or $simplified_post_date
$my_insight->filename = basename(__FILE__, ".php");
//Same for every insight, must be set exactly this way
$my_insight->emphasis = Insight::EMPHASIS_MED;
//Set emphasis optionally, default is Insight::EMPHASIS_LOW
//OPTIONAL: Attach related data of various types using Insight setter functions
//$my_insight->setPosts($my_insight_posts);
//$my_insight->setLinks($my_insight_links);
//$my_insight->setPeople($my_insight_people);
//$my_insight->setMilestones($my_insight_milestones);
//etc
$this->insight_dao->insertInsight($my_insight);
$this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
}
示例12: generateInsight
public function generateInsight(Instance $instance, $last_week_of_posts, $number_days)
{
parent::generateInsight($instance, $last_week_of_posts, $number_days);
$this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
$filename = basename(__FILE__, ".php");
$follow_dao = DAOFactory::getDAO('FollowDAO');
// Least likely followers based on follower-to-followee ratio
$least_likely_followers = $follow_dao->getLeastLikelyFollowersByDay($instance->network_user_id, $instance->network, 0, 3);
if (sizeof($least_likely_followers) > 0) {
//if not null, store insight
if (sizeof($least_likely_followers) > 1) {
$this->insight_dao->insertInsightDeprecated('least_likely_followers', $instance->id, $this->insight_date, "Standouts:", '<strong>' . sizeof($least_likely_followers) . " interesting users</strong> " . "followed {$this->username}.", $filename, Insight::EMPHASIS_LOW, serialize($least_likely_followers));
} else {
$this->insight_dao->insertInsightDeprecated('least_likely_followers', $instance->id, $this->insight_date, "Standout:", "An interesting user followed {$this->username}.", $filename, Insight::EMPHASIS_LOW, serialize($least_likely_followers));
}
}
// Verified followers
$verified_followers = $follow_dao->getVerifiedFollowersByDay($instance->network_user_id, $instance->network, 0, 3);
if (sizeof($verified_followers) > 0) {
//if not null, store insight
if (sizeof($verified_followers) > 1) {
$this->insight_dao->insertInsightDeprecated('verified_followers', $instance->id, $this->insight_date, "Verified followers!", '<strong>' . sizeof($verified_followers) . " verified users</strong> " . "followed {$this->username}.", $filename, Insight::EMPHASIS_LOW, serialize($verified_followers));
} else {
$this->insight_dao->insertInsightDeprecated('verified_followers', $instance->id, $this->insight_date, "Verified follower!", "A verified user followed {$this->username}.", $filename, Insight::EMPHASIS_LOW, serialize($verified_followers));
}
}
$this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
}
示例13: generateInsight
public function generateInsight(Instance $instance, $last_week_of_posts, $number_days)
{
parent::generateInsight($instance, $last_week_of_posts, $number_days);
$this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
$archived_posts_in_hundreds = intval($instance->total_posts_in_system / 100);
if ($archived_posts_in_hundreds > 0) {
$insight_baseline_slug = "archived_posts_" . $archived_posts_in_hundreds;
$insight_baseline_dao = DAOFactory::getDAO('InsightBaselineDAO');
if (!$insight_baseline_dao->doesInsightBaselineExist($insight_baseline_slug, $instance->id)) {
$insight_baseline_dao->insertInsightBaseline($insight_baseline_slug, $instance->id, $archived_posts_in_hundreds);
$config = Config::getInstance();
switch ($instance->network) {
case "twitter":
$posts_term = "tweets";
break;
case "foursquare":
$posts_term = "checkins";
break;
default:
$posts_term = "posts";
}
$text = "ThinkUp has captured over <strong>" . number_format($archived_posts_in_hundreds * 100) . ' ' . $posts_term . '</strong> by ' . $this->username . '.';
$this->insight_dao->insertInsight("archived_posts", $instance->id, $this->insight_date, "Archived:", $text, basename(__FILE__, ".php"), Insight::EMPHASIS_MED);
}
}
$this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
}
示例14: generateInsight
public function generateInsight(Instance $instance, $last_week_of_posts, $number_days)
{
parent::generateInsight($instance, $last_week_of_posts, $number_days);
$this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
$existing_insight = $this->insight_dao->getInsight("posts_on_this_day_popular_flashback", $instance->id, $this->insight_date);
if (!isset($existing_insight)) {
//Generate flashback post list
$post_dao = DAOFactory::getDAO('PostDAO');
$flashback_posts = $post_dao->getOnThisDayFlashbackPosts($instance->network_user_id, $instance->network, $this->insight_date);
$most_popular_post = null;
$most_responses = 0;
if (isset($flashback_posts) && sizeof($flashback_posts) > 0) {
foreach ($flashback_posts as $post) {
$total_responses = $post->reply_count_cache + $post->all_retweets + $post->favlike_count_cache;
if ($total_responses > 0 && $total_responses > $most_responses) {
$most_popular_post = $post;
$most_responses = $total_responses;
}
}
if (isset($most_popular_post)) {
$post_year = date(date('Y', strtotime($most_popular_post->pub_date)));
$current_year = date('Y');
$number_of_years_ago = $current_year - $post_year;
$plural = $number_of_years_ago > 1 ? 's' : '';
$insight_text = "{$this->username}'s most popular post <strong>{$number_of_years_ago} year{$plural} ago" . "</strong> today was:";
$this->insight_dao->insertInsight("posts_on_this_day_popular_flashback", $instance->id, $this->insight_date, "Time machine:", $insight_text, basename(__FILE__, ".php"), Insight::EMPHASIS_LOW, serialize($most_popular_post));
}
}
}
$this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
}
示例15: generateInsight
public function generateInsight(Instance $instance, User $user, $last_week_of_posts, $number_days)
{
if ($instance->network == 'twitter' || $instance->network == 'test_no_monthly') {
parent::generateInsight($instance, $user, $last_week_of_posts, $number_days);
$this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
$monthly = 0;
$weekly = 0;
if ($instance->network == 'twitter') {
$weekly = 6;
$monthly = 28;
} else {
if ($instance->network == 'test_no_monthly') {
$monthly = 0;
$weekly = 2;
}
}
$did_monthly = false;
if ($monthly && self::shouldGenerateMonthlyInsight($this->slug, $instance, 'today', false, $monthly)) {
$post_dao = DAOFactory::getDAO('PostDAO');
$posts = $post_dao->getAllPostsByUsernameOrderedBy($instance->network_username, $instance->network, $count = 0, $order_by = "pub_date", $in_last_x_days = date('t'), $iterator = false, $is_public = false);
$this->generateMonthlyInsight($instance, $posts);
$did_monthly = true;
}
$do_weekly = $weekly && !$did_monthly;
if ($do_weekly && self::shouldGenerateWeeklyInsight($this->slug, $instance, 'today', false, $weekly)) {
$this->generateWeeklyInsight($instance, $last_week_of_posts);
}
$this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
}
}