Пример #1
0
void UserLoginData::AppendUserFriends(MyUtil::Int2IntSeqMap& result, 
									const MyUtil::IntSeq& userFriends, 	
									const MyUtil::Int2IntSeqMap& negtiveFriendsMap) {
	MCE_INFO("[UserLoginData] AppendUserFriends");
	for (Int2IntSeqMap::iterator iter = result.begin();
			iter != result.end(); ++iter) {
		IntSeq& recommendList = iter->second;
		IntSeq tempRecommendList(recommendList);

		Int2IntSeqMap::const_iterator fIt = negtiveFriendsMap.find(iter->first);

		if (fIt != negtiveFriendsMap.end() && !recommendList.empty()) {
			for (IntSeq::const_iterator it = userFriends.begin();
					it != userFriends.end(); ++it) {
				if (find(tempRecommendList.begin(), tempRecommendList.end(), *it) != tempRecommendList.end()) {  //过滤好友中已经推出的好友
					continue;
				}

				UserLoginMapType::iterator ff = _userLoginMap.find( *it );
				if (ff == _userLoginMap.end() || (int)ff->second.count() < ACTIVEDAYS) {                  //过滤不活跃的推荐
					continue;
				}
				
				vector<int>::const_iterator userFriendIter = lower_bound(fIt->second.begin(), fIt->second.end(), *it);    //过滤好友列表
				if (userFriendIter == fIt->second.end() || *userFriendIter != *it) {
					recommendList.push_back(*it);
				}
			}
		}
	}
}
Пример #2
0
void UserLoginData::AppendSingleRelationFriend(int userId, MyUtil::Int2IntSeqMap& result) {
	HotFeedSeq singleFeedList = HotFeedRecommendCacheAdapter::instance().Get(userId, -1);

	ostringstream singleFeedListStream;
	for (HotFeedSeq::iterator iter = singleFeedList.begin();
			iter != singleFeedList.end(); ++iter) {
		if (result.find(iter->userId) == result.end()) {
			result.insert(make_pair<int, IntSeq>(iter->userId, IntSeq()));
			singleFeedListStream << iter->userId << ", ";
		}
	}
	singleFeedListStream << singleFeedList.size();
	MCE_INFO("[UserLoginData] AppendSingleRelationFriend userId(" << userId << ") detail " << singleFeedListStream.str());
}