the-algorithm/home-mixer/server/src/main/scala/com/twitter/home_mixer/marshaller/request/HomeMixerDebugParamsUnmarshaller.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

28 lines
975 B
Scala

package com.twitter.home_mixer.marshaller.request
import com.twitter.home_mixer.model.request.HomeMixerDebugOptions
import com.twitter.home_mixer.{thriftscala => t}
import com.twitter.product_mixer.core.functional_component.marshaller.request.FeatureValueUnmarshaller
import com.twitter.product_mixer.core.model.marshalling.request.DebugParams
import com.twitter.util.Time
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class HomeMixerDebugParamsUnmarshaller @Inject() (
featureValueUnmarshaller: FeatureValueUnmarshaller) {
def apply(debugParams: t.DebugParams): DebugParams = {
DebugParams(
featureOverrides = debugParams.featureOverrides.map { map =>
map.mapValues(featureValueUnmarshaller(_)).toMap
},
debugOptions = debugParams.debugOptions.map { options =>
HomeMixerDebugOptions(
requestTimeOverride = options.requestTimeOverrideMillis.map(Time.fromMilliseconds)
)
}
)
}
}