当前位置: 首页>>代码示例>>PHP>>正文


PHP myPartnerUtils::collectPartnerStatisticsFromDWH方法代码示例

本文整理汇总了PHP中myPartnerUtils::collectPartnerStatisticsFromDWH方法的典型用法代码示例。如果您正苦于以下问题:PHP myPartnerUtils::collectPartnerStatisticsFromDWH方法的具体用法?PHP myPartnerUtils::collectPartnerStatisticsFromDWH怎么用?PHP myPartnerUtils::collectPartnerStatisticsFromDWH使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在myPartnerUtils的用法示例。


在下文中一共展示了myPartnerUtils::collectPartnerStatisticsFromDWH方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doPartnerUsage

 public static function doPartnerUsage(Partner $partner)
 {
     KalturaLog::debug("Validating partner [" . $partner->getId() . "]");
     if ($partner->getExtendedFreeTrail()) {
         KalturaLog::debug("Partner [" . $partner->getId() . "] trial account has extension");
         if ($partner->getExtendedFreeTrailExpiryDate() < time()) {
             //ExtendedFreeTrail ended
             $partner->setExtendedFreeTrail(null);
             $partner->setExtendedFreeTrailExpiryDate(null);
             $partner->setExtendedFreeTrailExpiryReason('');
         } else {
             //ExtendedFreeTrail
             if ($partner->getExtendedFreeTrailExpiryDate() < time() + dateUtils::DAY * 7 && !$partner->getExtendedFreeTrailEndsWarning()) {
                 $partner->setExtendedFreeTrailEndsWarning(true);
                 $partner->save();
                 $email_link_hash = 'pid=' . $partner->getId() . '&h=' . self::getEmailLinkHash($partner->getId(), $partner->getSecret());
                 $mail_parmas = array($partner->getAdminName(), $email_link_hash);
                 myPartnerUtils::notifiyPartner(myPartnerUtils::KALTURA_EXTENED_FREE_TRAIL_ENDS_WARNING, $partner, $mail_parmas);
             }
             KalturaLog::debug("Partner [" . $partner->getId() . "] trial account extended");
             return;
         }
     }
     $should_block_delete_partner = true;
     $block_notification_grace = time() - dateUtils::DAY * self::BLOCKING_DAYS_GRACE;
     $delete_grace = time() - dateUtils::DAY * 30;
     $packages = new PartnerPackages();
     $partnerPackage = $packages->getPackageDetails($partner->getPartnerPackage());
     $report_date = date('Y-m') . '-01';
     // We are now working with the DWH and a stored-procedure, and not with record type 6 on partner_activity.
     $report_date = dateUtils::todayOffset(-1);
     list($totalStorage, $totalUsage, $totalTraffic) = myPartnerUtils::collectPartnerStatisticsFromDWH($partner, $partnerPackage, $report_date);
     $totalUsageGB = $totalUsage / 1024 / 1024;
     // from KB to GB
     $percent = round($totalUsageGB / $partnerPackage['cycle_bw'] * 100, 2);
     KalturaLog::debug("percent (" . $partner->getId() . ") is: {$percent}");
     $email_link_hash = 'pid=' . $partner->getId() . '&h=' . self::getEmailLinkHash($partner->getId(), $partner->getSecret());
     $email_link_hash_adOpt = $email_link_hash . '&type=adOptIn';
     /* mindtouch partners - extra mail parameter */
     $mindtouch_notice = ' ';
     if ($partner->getType() == 103) {
         $mindtouch_notice = '<BR><BR>Note: You must be a MindTouch paying customer to upgrade your video service. If you are not a paying MindTouch customer, contact MindTouch: http://www.mindtouch.com/about_mindtouch/contact_mindtouch to get a quote.<BR><BR>';
     }
     if ($percent >= 80 && $percent < 100 && !$partner->getEightyPercentWarning()) {
         KalturaLog::debug("partner " . $partner->getId() . " reached 80% - setting first warning");
         /* prepare mail job, and set EightyPercentWarning() to true/date */
         $partner->setEightyPercentWarning(time());
         $partner->setUsageLimitWarning(0);
         $body_params = array($partner->getAdminName(), $partnerPackage['cycle_bw'], $mindtouch_notice, round($totalUsageGB, 2), $email_link_hash);
         myPartnerUtils::notifiyPartner(myPartnerUtils::KALTURA_PACKAGE_EIGHTY_PERCENT_WARNING, $partner, $body_params);
     } elseif ($percent >= 80 && $percent < 100 && $partner->getEightyPercentWarning() && !$partner->getUsageLimitWarning()) {
         KalturaLog::log("passed the 80%, assume notification sent, nothing to do.");
     } elseif ($percent < 80 && $partner->getEightyPercentWarning()) {
         KalturaLog::debug("partner " . $partner->getId() . " was 80%, now not. clearing warnings");
         /* clear getEightyPercentWarning */
         $partner->setEightyPercentWarning(0);
         $partner->setUsageLimitWarning(0);
     } elseif ($percent >= 100 && !$partner->getUsageLimitWarning()) {
         KalturaLog::debug("partner " . $partner->getId() . " reached 100% - setting second warning");
         /* prepare mail job, and set getUsageLimitWarning() date */
         $partner->setUsageLimitWarning(time());
         $body_params = array($partner->getAdminName(), $mindtouch_notice, round($totalUsageGB, 2), $email_link_hash);
         myPartnerUtils::notifiyPartner(myPartnerUtils::KALTURA_PACKAGE_LIMIT_WARNING_1, $partner, $body_params);
     } elseif ($percent >= 100 && $partnerPackage['cycle_fee'] == 0 && $partner->getUsageLimitWarning() > 0 && $partner->getUsageLimitWarning() <= $block_notification_grace && $partner->getUsageLimitWarning() > $delete_grace && $partner->getStatus() != Partner::PARTNER_STATUS_CONTENT_BLOCK) {
         KalturaLog::debug("partner " . $partner->getId() . " reached 100% " . self::BLOCKING_DAYS_GRACE . " days ago - sending block email and blocking partner");
         /* send block email and block partner */
         $body_params = array($partner->getAdminName(), $mindtouch_notice, round($totalUsageGB, 2), $email_link_hash);
         myPartnerUtils::notifiyPartner(myPartnerUtils::KALTURA_PACKAGE_LIMIT_WARNING_2, $partner, $body_params);
         if ($should_block_delete_partner) {
             $partner->setStatus(Partner::PARTNER_STATUS_CONTENT_BLOCK);
         }
     } elseif ($percent >= 120 && $partnerPackage['cycle_fee'] != 0 && $partner->getUsageLimitWarning() <= $block_notification_grace) {
         $body_params = array($partner->getAdminName(), round($totalUsageGB, 2));
         myPartnerUtils::notifiyPartner(myPartnerUtils::KALTURA_PAID_PACKAGE_SUGGEST_UPGRADE, $partner, $body_params);
     } elseif ($percent >= 100 && $partnerPackage['cycle_fee'] == 0 && $partner->getUsageLimitWarning() > 0 && $partner->getUsageLimitWarning() <= $delete_grace && $partner->getStatus() == Partner::PARTNER_STATUS_CONTENT_BLOCK) {
         KalturaLog::debug("partner " . $partner->getId() . " reached 100% a month ago - deleting partner");
         /* delete partner */
         $body_params = array($partner->getAdminName());
         myPartnerUtils::notifiyPartner(myPartnerUtils::KALTURA_DELETE_ACCOUNT, $partner, $body_params);
         if ($should_block_delete_partner) {
             $partner->setStatus(Partner::PARTNER_STATUS_DELETED);
         }
     } elseif ($percent < 80 && ($partner->getUsageLimitWarning() || $partner->getEightyPercentWarning())) {
         KalturaLog::debug("partner " . $partner->getId() . " OK");
         // PARTNER OK
         // resetting status and warnings should only be done manually
         //$partner->setStatus(1);
         $partner->setEightyPercentWarning(0);
         $partner->setUsageLimitWarning(0);
     }
     $partner->save();
 }
开发者ID:dozernz,项目名称:server,代码行数:92,代码来源:myPartnerUtils.class.php

示例2: getStatisticsAction

 /**
  * Get usage statistics for a partner
  * Calculation is done according to partner's package
  *
  * @action getStatistics
  * @return KalturaPartnerStatistics
  * 
  * @throws APIErrors::UNKNOWN_PARTNER_ID
  */
 public function getStatisticsAction()
 {
     $dbPartner = PartnerPeer::retrieveByPK($this->getPartnerId());
     if (!$dbPartner) {
         throw new KalturaAPIException(APIErrors::UNKNOWN_PARTNER_ID, $this->getPartnerId());
     }
     $packages = new PartnerPackages();
     $partnerUsage = new KalturaPartnerStatistics();
     $partnerPackage = $packages->getPackageDetails($dbPartner->getPartnerPackage());
     $report_date = date("Y-m-d", time());
     list($totalStorage, $totalUsage, $totalTraffic) = myPartnerUtils::collectPartnerStatisticsFromDWH($dbPartner, $partnerPackage, $report_date);
     $partnerUsage->hosting = round($totalStorage / 1024, 2);
     // from MB to GB
     $totalUsageGB = round($totalUsage / 1024 / 1024, 2);
     // from KB to GB
     if ($partnerPackage) {
         $partnerUsage->usagePercent = round($totalUsageGB / $partnerPackage['cycle_bw'] * 100, 2);
         $partnerUsage->packageBandwidthAndStorage = $partnerPackage['cycle_bw'];
     }
     if ($totalTraffic) {
         $partnerUsage->bandwidth = round($totalTraffic / 1024 / 1024, 2);
         // from KB to GB
     }
     $partnerUsage->usage = $totalUsageGB;
     $partnerUsage->reachedLimitDate = $dbPartner->getUsageLimitWarning();
     return $partnerUsage;
 }
开发者ID:DBezemer,项目名称:server,代码行数:36,代码来源:PartnerService.php


注:本文中的myPartnerUtils::collectPartnerStatisticsFromDWH方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。