public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { $obj_type = $this->getPM("obj_type"); $obj_id = $this->getPM("obj_id"); $command = $this->getPM("command"); $value = $this->getP("value"); $extra_info = $this->getP("extra_info"); if ($obj_type == "entry") { $entry = entryPeer::retrieveByPK($obj_id); if ($command == "view") { PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_KDP, PartnerActivity::PARTNER_SUB_ACTIVITY_KDP_VIEWS); myStatisticsMgr::incEntryViews($entry); } elseif ($command == "play") { PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_KDP, PartnerActivity::PARTNER_SUB_ACTIVITY_KDP_PLAYS); myStatisticsMgr::incEntryPlays($entry); } } elseif ($obj_type == "kshow") { $kshow = kshowPeer::retrieveByPK($obj_id); if ($command == "view") { PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_KDP, PartnerActivity::PARTNER_SUB_ACTIVITY_KDP_VIEWS); myStatisticsMgr::incKshowViews($kshow); } elseif ($command == "play") { PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_KDP, PartnerActivity::PARTNER_SUB_ACTIVITY_KDP_PLAYS); myStatisticsMgr::incKshowPlays($kshow); } } $this->addMsg("collectedStats", "{$obj_type}, {$obj_id}, {$command}, {$value}, {$extra_info}"); }
unset($entries); entryPeer::clearInstancePool(); fprintf($stderr, "{$i}\r"); } $connection = Propel::getConnection(); foreach ($stats as $partner_id => $dates) { foreach ($dates as $date => $pstats) { /** * we are deleting entries for a specific partner on a specific date. * * if we run twice on the same date, this way we only re-insert partners found in this run * and not in the first run. */ $query = "DELETE FROM " . PartnerActivityPeer::TABLE_NAME . " WHERE " . PartnerActivityPeer::ACTIVITY . "=" . PartnerActivity::PARTNER_ACTIVITY_STORAGE . " AND " . PartnerActivityPeer::PARTNER_ID . "=" . $partner_id . " AND " . PartnerActivityPeer::ACTIVITY_DATE . "='" . $date . "'"; $connection->exec($query); //print "$partner_id $date ".$pstats["size"]." ".$pstats["count"]."\n"; // output partner ID and date, print "{$partner_id} {$date} \n"; PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_STORAGE, PartnerActivity::PARTNER_SUB_ACTIVITY_STORAGE_SIZE, floor($pstats["size"] / 1024), $date); PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_STORAGE, PartnerActivity::PARTNER_SUB_ACTIVITY_STORAGE_COUNT, $pstats["count"], $date); } } foreach ($kusers as $kuser_id => $size) { $kuser = kuserPeer::retrieveByPK($kuser_id); if ($kuser) { $kuser->setStorageSize($kuser->getStorageSize() + $size); $kuser->save(); } unset($kuser); //echo 'kuser '.$kuser_id.' has total daily size of '.$size.PHP_EOL; }