the-algorithm/follow-recommendations-service/common/src/main/scala/com/twitter/follow_recommendations/common/transforms/ranker_id/RandomRankerIdTransform.scala
twitter-team ef4c5eb65e Twitter Recommendation Algorithm
Please note we have force-pushed a new initial commit in order to remove some publicly-available Twitter user information. Note that this process may be required in the future.
2023-03-31 17:36:31 -05:00

25 lines
889 B
Scala

package com.twitter.follow_recommendations.common.transforms.ranker_id
import com.google.inject.Inject
import com.google.inject.Singleton
import com.twitter.follow_recommendations.common.base.GatedTransform
import com.twitter.follow_recommendations.common.models.CandidateUser
import com.twitter.follow_recommendations.common.models.Score
import com.twitter.stitch.Stitch
import com.twitter.timelines.configapi.HasParams
/**
* This class appends each candidate's rankerIds with the RandomRankerId.
* This is primarily for determining if a candidate was generated via random shuffling.
*/
@Singleton
class RandomRankerIdTransform @Inject() () extends GatedTransform[HasParams, CandidateUser] {
override def transform(
target: HasParams,
candidates: Seq[CandidateUser]
): Stitch[Seq[CandidateUser]] = {
Stitch.value(candidates.map(_.addScore(Score.RandomScore)))
}
}