mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-06-01 08:48:46 +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.
30 lines
1.0 KiB
Scala
30 lines
1.0 KiB
Scala
package com.twitter.timelineranker.common
|
|
|
|
import com.twitter.finagle.stats.StatsReceiver
|
|
import com.twitter.servo.util.FutureArrow
|
|
import com.twitter.timelineranker.core.CandidateEnvelope
|
|
import com.twitter.timelines.clients.relevance_search.SearchClient
|
|
import com.twitter.timelines.model.TweetId
|
|
import com.twitter.util.Future
|
|
|
|
trait RecapHydrationSearchResultsTransformBase
|
|
extends FutureArrow[CandidateEnvelope, CandidateEnvelope] {
|
|
protected def statsReceiver: StatsReceiver
|
|
protected def searchClient: SearchClient
|
|
private[this] val numResultsFromSearchStat = statsReceiver.stat("numResultsFromSearch")
|
|
|
|
def tweetIdsToHydrate(envelope: CandidateEnvelope): Seq[TweetId]
|
|
|
|
override def apply(envelope: CandidateEnvelope): Future[CandidateEnvelope] = {
|
|
searchClient
|
|
.getTweetsScoredForRecap(
|
|
envelope.query.userId,
|
|
tweetIdsToHydrate(envelope),
|
|
envelope.query.earlybirdOptions
|
|
).map { results =>
|
|
numResultsFromSearchStat.add(results.size)
|
|
envelope.copy(searchResults = results)
|
|
}
|
|
}
|
|
}
|