示例#1
0
 public function getUserEditInfo($userId)
 {
     global $wgMemc;
     $key = wfForeignMemcKey('huiji', '', 'user_daily_edit', 'all_days', $userId);
     $today = date("Y-m-d");
     $oneYearAgo = date("Y-m-d", strtotime("-1 year"));
     $yesterday = date("Y-m-d", strtotime("-1 day"));
     $userEditInfo = self::getUserEditInfoCache($userId);
     if ($userEditInfo == '') {
         $receive = RecordStatistics::getEditRecordsFromUserIdGroupByDay($userId, $oneYearAgo, $yesterday);
         if ($receive->status == 'success') {
             $userEditInfo = $receive->result;
             $userEditInfo['lastSeen'] = $today;
             $wgMemc->set($key, $userEditInfo);
         } else {
             $userEditInfo = false;
         }
     } else {
         if ($today == $userEditInfo['lastSeen']) {
             return $userEditInfo;
         }
         $receive = RecordStatistics::getEditRecordsFromUserIdGroupByDay($userId, $userEditInfo['lastSeen'], $yesterday);
         if ($receive->status == 'success') {
             $EditSinceLastSeen = $receive->result;
             $userEditInfo = array_merge($userEditInfo, $EditSinceLastSeen);
             $userEditInfo['lastSeen'] = $today;
             $wgMemc->set($key, $userEditInfo);
         } else {
             $userEditInfo = false;
         }
     }
     return $userEditInfo;
 }
示例#2
0
 public function getUserEditInfo($userId)
 {
     global $wgMemc;
     $key = wfForeignMemcKey('huiji', '', 'user_daily_edit', 'all_days', $userId);
     $today = date("Y-m-d");
     $oneYearAgo = date("Y-m-d", strtotime("-1 year"));
     $yesterday = date("Y-m-d", strtotime("-1 day"));
     $userEditInfo = self::getUserEditInfoCache($userId);
     if ($userEditInfo == '') {
         $receive = RecordStatistics::getEditRecordsFromUserIdGroupByDay($userId, $oneYearAgo, $yesterday);
         if ($receive->status == 'success') {
             $userEditInfo = $receive->result;
             $userEditInfo['lastSeen'] = $today;
             $wgMemc->set($key, $userEditInfo);
         } else {
             throw new Exception("Error getUserEditInfo/getEditRecordsFromUserIdGroupByDay Bad Request");
         }
     } else {
         if ($today == $userEditInfo['lastSeen']) {
             return $userEditInfo;
         }
         $Delres = array();
         if ($userEditInfo['lastSeen'] == $yesterday) {
             $receive = RecordStatistics::getPageEditCountOnWikiSiteFromUserId($userId, '', $yesterday, $yesterday);
             if ($receive->status == 'success') {
                 $Beres = $receive->result;
                 $Delres['_id'] = $yesterday;
                 $Delres['value'] = $Beres;
                 $resData[] = (object) $Delres;
                 $userEditInfo = array_merge($userEditInfo, $resData);
                 $userEditInfo['lastSeen'] = $today;
                 $wgMemc->set($key, $userEditInfo);
             } else {
                 throw new Exception("Error getUserEditInfo/getPageEditCountOnWikiSiteFromUserId Bad Request");
             }
         } else {
             $receive = RecordStatistics::getEditRecordsFromUserIdGroupByDay($userId, $userEditInfo['lastSeen'], $yesterday);
             if ($receive->status == 'success') {
                 $EditSinceLastSeen = $receive->result;
                 $userEditInfo = array_merge($userEditInfo, $EditSinceLastSeen);
                 $userEditInfo['lastSeen'] = $today;
                 $wgMemc->set($key, $userEditInfo);
             } else {
                 throw new Exception("Error getUserEditInfo/getEditRecordsFromUserIdGroupByDay Bad Request");
             }
         }
     }
     return $userEditInfo;
 }
示例#3
0
 static function getAllPageEditRecordsFromUserIdGroupByDay($userId, $fromTime, $toTime)
 {
     $faked = RecordStatistics::getFakedPageEditRecordsFromUserIdGroupByDay($userId, $fromTime, $toTime);
     $real = RecordStatistics::getEditRecordsFromUserIdGroupByDay($userId, $fromTime, $toTime);
     $out = new stdClass();
     $result = array();
     $temp = array();
     if ($faked->status == 'success' && $real->status == 'success') {
         foreach ($real->result as $object) {
             if ($object->_id != NULL) {
                 $result[$object->_id] = $object->value;
             }
         }
         foreach ($faked->result as $object) {
             if ($object->_id == NULL) {
                 break;
             }
             if (isset($result[$object->_id])) {
                 $result[$object->_id] += $object->value;
             } else {
                 $result[$object->_id] = $object->value;
             }
         }
         foreach ($result as $key => $value) {
             $ob = new stdClass();
             $ob->_id = $key;
             $ob->value = $value;
             array_push($temp, $ob);
         }
         $result = $temp;
         $out->status = 'success';
     } else {
         if ($faked->status == 'success') {
             $result = $faked->result;
             $out->status = 'success';
         } else {
             if ($real->status == 'success') {
                 $result = $real->result;
                 $out->status = 'success';
             } else {
                 $out->status = 'fail';
             }
         }
     }
     $out->result = $result;
     return $out;
 }