mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-06-13 06:38:52 +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.
32 lines
1.2 KiB
Scala
32 lines
1.2 KiB
Scala
package com.twitter.product_mixer.component_library.candidate_source.explore_ranker
|
|
|
|
import com.twitter.explore_ranker.{thriftscala => t}
|
|
import com.twitter.product_mixer.core.functional_component.candidate_source.CandidateSource
|
|
import com.twitter.product_mixer.core.model.common.identifier.CandidateSourceIdentifier
|
|
import com.twitter.stitch.Stitch
|
|
import javax.inject.Inject
|
|
import javax.inject.Singleton
|
|
|
|
@Singleton
|
|
class ExploreRankerCandidateSource @Inject() (
|
|
exploreRankerService: t.ExploreRanker.MethodPerEndpoint)
|
|
extends CandidateSource[t.ExploreRankerRequest, t.ImmersiveRecsResult] {
|
|
|
|
override val identifier: CandidateSourceIdentifier = CandidateSourceIdentifier("ExploreRanker")
|
|
|
|
override def apply(
|
|
request: t.ExploreRankerRequest
|
|
): Stitch[Seq[t.ImmersiveRecsResult]] = {
|
|
Stitch
|
|
.callFuture(exploreRankerService.getRankedResults(request))
|
|
.map {
|
|
case t.ExploreRankerResponse(
|
|
t.ExploreRankerProductResponse
|
|
.ImmersiveRecsResponse(t.ImmersiveRecsResponse(immersiveRecsResults))) =>
|
|
immersiveRecsResults
|
|
case response =>
|
|
throw new UnsupportedOperationException(s"Unknown response type: $response")
|
|
}
|
|
}
|
|
}
|