mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-06-14 07:08:53 +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.
28 lines
923 B
Scala
28 lines
923 B
Scala
package com.twitter.follow_recommendations.common.candidate_sources.base
|
|
|
|
import com.twitter.follow_recommendations.common.models.CandidateUser
|
|
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 com.twitter.strato.client.Fetcher
|
|
|
|
abstract class StratoFetcherSource[K, U, V](
|
|
fetcher: Fetcher[K, U, V],
|
|
view: U,
|
|
override val identifier: CandidateSourceIdentifier)
|
|
extends CandidateSource[K, CandidateUser] {
|
|
|
|
def map(user: K, v: V): Seq[CandidateUser]
|
|
|
|
override def apply(target: K): Stitch[Seq[CandidateUser]] = {
|
|
fetcher
|
|
.fetch(target, view)
|
|
.map { result =>
|
|
result.v
|
|
.map { candidates => map(target, candidates) }
|
|
.getOrElse(Nil)
|
|
.map(_.withCandidateSource(identifier))
|
|
}
|
|
}
|
|
}
|