mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-06-13 22:58:54 +02:00
ef4c5eb65e
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.
34 lines
1.4 KiB
Scala
34 lines
1.4 KiB
Scala
package com.twitter.timelineranker.common
|
|
|
|
import com.twitter.servo.util.FutureArrow
|
|
import com.twitter.timelineranker.core.CandidateEnvelope
|
|
import com.twitter.timelineranker.core.HydratedCandidatesAndFeaturesEnvelope
|
|
import com.twitter.timelineranker.model.RecapQuery
|
|
import com.twitter.util.Future
|
|
|
|
/**
|
|
* Fetches all data required for feature hydration and generates the HydratedCandidatesAndFeaturesEnvelope
|
|
* @param tweetHydrationAndFilteringPipeline Pipeline which fetches the candidate tweets, hydrates and filters them
|
|
* @param languagesService Fetch user languages, required for feature hydration
|
|
* @param userProfileInfoService Fetch user profile info, required for feature hydration
|
|
*/
|
|
class FeatureHydrationDataTransform(
|
|
tweetHydrationAndFilteringPipeline: FutureArrow[RecapQuery, CandidateEnvelope],
|
|
languagesService: UserLanguagesTransform,
|
|
userProfileInfoService: UserProfileInfoTransform)
|
|
extends FutureArrow[RecapQuery, HydratedCandidatesAndFeaturesEnvelope] {
|
|
override def apply(request: RecapQuery): Future[HydratedCandidatesAndFeaturesEnvelope] = {
|
|
Future
|
|
.join(
|
|
languagesService(request),
|
|
userProfileInfoService(request),
|
|
tweetHydrationAndFilteringPipeline(request)).map {
|
|
case (languages, userProfileInfo, transformedCandidateEnvelope) =>
|
|
HydratedCandidatesAndFeaturesEnvelope(
|
|
transformedCandidateEnvelope,
|
|
languages,
|
|
userProfileInfo)
|
|
}
|
|
}
|
|
}
|