本文整理汇总了PHP中PluginRegistrarInsights类的典型用法代码示例。如果您正苦于以下问题:PHP PluginRegistrarInsights类的具体用法?PHP PluginRegistrarInsights怎么用?PHP PluginRegistrarInsights使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PluginRegistrarInsights类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: crawl
public function crawl()
{
$logger = Logger::getInstance();
// Include all the insights files so they register themselves
foreach (glob(THINKUP_WEBAPP_PATH . "plugins/insightsgenerator/insights/*.php") as $filename) {
require_once $filename;
}
//Get instances by owner
$instance_dao = DAOFactory::getDAO('InstanceDAO');
$owner_dao = DAOFactory::getDAO('OwnerDAO');
$current_owner = $owner_dao->getByEmail(Session::getLoggedInUser());
$instances = $instance_dao->getByOwner($current_owner, false, true);
// Get posts for last 7 days
$number_days = 7;
$post_dao = DAOFactory::getDAO('PostDAO');
$insights_plugin_registrar = PluginRegistrarInsights::getInstance();
foreach ($instances as $instance) {
$last_week_of_posts = $post_dao->getAllPostsByUsernameOrderedBy($instance->network_username, $network = $instance->network, $count = 0, $order_by = "pub_date", $in_last_x_days = $number_days, $iterator = false, $is_public = false);
$insights_plugin_registrar->runRegisteredPluginsInsightGeneration($instance, $last_week_of_posts, $number_days);
$logger->logUserSuccess("Completed insight generation for " . $instance->network_username . " on " . $instance->network, __METHOD__ . ',' . __LINE__);
}
}
示例2:
}
}
if ($video_dao->doesUserHaveVideosWithLikesSinceDate($instance->network_username, $instance->network, 90, $since_date)) {
//Save average likes over past 90 days
$average_like_count_90_days = null;
$average_like_count_90_days = $video_dao->getAverageLikeCount($instance->network_username, $instance->network, 90, $since_date);
if ($average_like_count_90_days != null) {
$insight_baseline_dao->insertInsightBaseline('avg_like_count_last_90_days', $instance->id, $average_like_count_90_days, $since_date);
$this->logger->logSuccess("Averaged {$average_like_count_90_days} likes in the 90 days before " . $since_date, __METHOD__ . ',' . __LINE__);
}
//Save like high for last 90 days
$high_like_count_90_days = $video_dao->getHighestLikes($instance->network_username, $instance->network, 90, $since_date);
if ($high_like_count_90_days != null) {
$insight_baseline_dao->insertInsightBaseline('high_like_count_last_90_days', $instance->id, $high_like_count_90_days, $since_date);
$this->logger->logSuccess("High of {$high_like_count_90_days} likes in the 90 days before " . $since_date, __METHOD__ . ',' . __LINE__);
}
}
if ($video_dao->doesUserHaveVideosWithLikesSinceDate($instance->network_username, $instance->network, 365, $since_date)) {
//Save like high for last 365 days
$high_like_count_365_days = $video_dao->getHighestLikes($instance->network_username, $instance->network, 365, $since_date);
if ($high_like_count_365_days != null) {
$insight_baseline_dao->insertInsightBaseline('high_like_count_last_365_days', $instance->id, $high_like_count_365_days, $since_date);
$this->logger->logSuccess("High of {$high_like_count_365_days} likes in the 365 days before " . $since_date, __METHOD__ . ',' . __LINE__);
}
}
$days_ago++;
}
}
}
$insights_plugin_registrar = PluginRegistrarInsights::getInstance();
$insights_plugin_registrar->registerInsightPlugin('LikeSpikeInsight');
示例3: crawl
public function crawl()
{
$logger = Logger::getInstance();
// Include all the insights files so they register themselves
foreach (glob(THINKUP_WEBAPP_PATH . "plugins/insightsgenerator/insights/*.php") as $filename) {
require_once $filename;
}
//Get instances by owner
$instance_dao = DAOFactory::getDAO('InstanceDAO');
$owner_dao = DAOFactory::getDAO('OwnerDAO');
$current_owner = $owner_dao->getByEmail(Session::getLoggedInUser());
$instances = $instance_dao->getByOwner($current_owner, false, true);
// Get posts for last 7 days
$number_days = 7;
$post_dao = DAOFactory::getDAO('PostDAO');
$insights_plugin_registrar = PluginRegistrarInsights::getInstance();
foreach ($instances as $instance) {
$last_week_of_posts = $post_dao->getAllPostsByUsernameOrderedBy($instance->network_username, $network = $instance->network, $count = 0, $order_by = "pub_date", $in_last_x_days = $number_days, $iterator = false, $is_public = false);
$insights_plugin_registrar->runRegisteredPluginsInsightGeneration($instance, $last_week_of_posts, $number_days);
$logger->logUserSuccess("Completed insight generation for " . $instance->network_username . " on " . $instance->network, __METHOD__ . ',' . __LINE__);
}
// Don't do email for regular users
if (!$current_owner->is_admin) {
return;
}
// Send email digest the first run after 4am
if ((int) date('G', $this->current_timestamp) >= 4) {
//Get plugin options
$plugin_option_dao = DAOFactory::GetDAO('PluginOptionDAO');
$options = $plugin_option_dao->getOptionsHash($this->folder_name, true);
//Get plugin ID
$plugin_dao = DAOFactory::getDAO('PluginDAO');
$plugin_id = $plugin_dao->getPluginId($this->folder_name);
//Get today's date
$today = date('Y-m-d', $this->current_timestamp);
$do_daily = false;
$do_weekly = false;
$last_daily = isset($options['last_daily_email']) ? $options['last_daily_email']->option_value : null;
if ($last_daily != $today) {
if ($last_daily === null) {
$plugin_option_dao->insertOption($plugin_id, 'last_daily_email', $today);
} else {
$plugin_option_dao->updateOption($options['last_daily_email']->id, 'last_daily_email', $today);
}
$do_daily = true;
}
$last_weekly = isset($options['last_weekly_email']) ? $options['last_weekly_email']->option_value : null;
if ($last_weekly != $today && date('w', $this->current_timestamp) == self::WEEKLY_DIGEST_DAY_OF_WEEK) {
if ($last_weekly === null) {
$plugin_option_dao->insertOption($plugin_id, 'last_weekly_email', $today);
} else {
$plugin_option_dao->updateOption($options['last_weekly_email']->id, 'last_weekly_email', $today);
}
$do_weekly = true;
}
if ($do_daily || $do_weekly) {
$owners = $owner_dao->getAllOwners();
}
if ($do_daily) {
foreach ($owners as $owner) {
if ($this->sendDailyDigest($owner, $options)) {
$logger->logUserSuccess("Mailed daily digest to " . $owner->email . ".", __METHOD__ . ',' . __LINE__);
}
}
}
if ($do_weekly) {
foreach ($owners as $owner) {
if ($this->sendWeeklyDigest($owner, $options)) {
$logger->logUserSuccess("Mailed weekly digest to " . $owner->email . ".", __METHOD__ . ',' . __LINE__);
}
}
}
}
}
示例4: destroyInstance
/**
* Provided only for tests that want to kill object in tearDown()
* @return void
*/
public static function destroyInstance()
{
if (isset(self::$instance)) {
self::$instance = null;
}
}