/** * 算法说明:根据用户注册时间来判断 * 以半年为中点,此时打分值为THRESHOLD_REMARK * 注册时间每增加或减少一天,打分值减少或增加DECREASE_RATE * 另外加入特殊处理,最近SPECIAL_TIME天注册的,打分值恒定为SPECIAL_REMARK */ public function test(ZombieKiller_Context $context) { $user = $context->get_current_user(); $his_followers = $this->_get_followers($user->id); $count = $this->_get_followers_verify_count($his_followers); $diff = $count - self::THRESHOLD_COUNT; $remark = $diff * self::DECREASE_RATE; $remark = self::THRESHOLD_REMARK + $remark; $remark = $remark < 0 ? 0 : $remark; $remark = $remark > 100 ? 100 : $remark; $remark = round($remark); return $remark; }
/** * 算法说明:根据用户注册时间来判断 * 以半年为中点,此时打分值为THRESHOLD_REMARK * 注册时间每增加或减少一天,打分值减少或增加DECREASE_RATE * 另外加入特殊处理,最近SPECIAL_TIME天注册的,打分值恒定为SPECIAL_REMARK */ public function test(ZombieKiller_Context $context) { $user = $context->get_current_user(); $followers_count = $user->followers_count; $friends_count = $user->friends_count; $the_rate = $followers_count / $friends_count; $diff = $the_rate - 1; $remark = $diff * self::DECREASE_RATE; $remark = self::THRESHOLD_REMARK - $remark; $remark = $remark < 0 ? 0 : $remark; $remark = $remark > 100 ? 100 : $remark; $remark = round($remark); return $remark; }
/** * 算法说明:根据用户注册时间来判断 * 以半年为中点,此时打分值为THRESHOLD_REMARK * 注册时间每增加或减少一天,打分值减少或增加DECREASE_RATE * 另外加入特殊处理,最近SPECIAL_TIME天注册的,打分值恒定为SPECIAL_REMARK */ public function test(ZombieKiller_Context $context) { $user = $context->get_current_user(); $followers_count = $user->followers_count; if ($followers_count < self::SPECIAL_COUNT) { $remark = self::SPECIAL_REMARK; } else { $diff = $followers_count - self::THRESHOLD_COUNT; $remark = $diff * self::DECREASE_RATE; $remark = self::THRESHOLD_REMARK - $remark; $remark = $remark < 0 ? 0 : $remark; $remark = $remark > 100 ? 100 : $remark; } $remark = round($remark); return $remark; }
/** * 算法说明:根据用户注册时间来判断 * 以半年为中点,此时打分值为THRESHOLD_REMARK * 注册时间每增加或减少一天,打分值减少或增加DECREASE_RATE * 另外加入特殊处理,最近SPECIAL_TIME天注册的,打分值恒定为SPECIAL_REMARK */ public function test(ZombieKiller_Context $context) { $user = $context->get_current_user(); $create_time = $user->create_time; $time_diff = time() - $create_time; if ($time_diff < 86400 * self::SPECIAL_TIME) { $remark = self::SPECIAL_REMARK; } else { $time_diff = self::THRESHOLD_DATE - $time_diff; $remark = $time_diff / 86400 * self::DECREASE_RATE; $remark = self::THRESHOLD_REMARK + $remark; $remark = $remark < 0 ? 0 : $remark; $remark = $remark > 100 ? 100 : $remark; } $remark = round($remark); return $remark; }
/** * 算法说明:根据用户注册时间来判断 * 以半年为中点,此时打分值为THRESHOLD_REMARK * 注册时间每增加或减少一天,打分值减少或增加DECREASE_RATE * 另外加入特殊处理,最近SPECIAL_TIME天注册的,打分值恒定为SPECIAL_REMARK */ public function test(ZombieKiller_Context $context) { $user = $context->get_current_user(); $remark = 50; if ($user->verified) { $remark += 100000; } if (strlen($user->domain) > 1) { $remark += 10; } if (strlen($user->description) > 100) { $remark += 10; } $remark = $remark < 0 ? 0 : $remark; $remark = $remark > 100 ? 100 : $remark; $remark = round($remark); return $remark; }
/** * 算法说明:根据用户注册时间来判断 * 以半年为中点,此时打分值为THRESHOLD_REMARK * 注册时间每增加或减少一天,打分值减少或增加DECREASE_RATE * 另外加入特殊处理,最近SPECIAL_TIME天注册的,打分值恒定为SPECIAL_REMARK */ public function test(ZombieKiller_Context $context) { $user = $context->get_current_user(); $followers_count = $user->followers_count; $root_user = $context->get_root_user(); $my_friends = $this->_get_friends($root_user); $his_followers = $this->_get_followers($user->id); $same_people_count = count(array_intersect($my_friends, $his_followers)); if ($same_people_count >= self::SPECIAL_COUNT) { $remark = self::SPECIAL_REMARK; } else { $diff = $same_people_count - self::THRESHOLD_COUNT; $remark = $diff * self::DECREASE_RATE; $remark = self::THRESHOLD_REMARK - $remark; $remark = $remark < 0 ? 0 : $remark; $remark = $remark > 100 ? 100 : $remark; } $remark = round($remark); return $remark; }