mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-06-27 13:36:03 +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.
25 lines
1.0 KiB
Scala
25 lines
1.0 KiB
Scala
package com.twitter.home_mixer.functional_component.gate
|
|
|
|
import com.twitter.home_mixer.model.request.DeviceContext.RequestContext
|
|
import com.twitter.home_mixer.model.request.HasDeviceContext
|
|
import com.twitter.product_mixer.core.functional_component.gate.Gate
|
|
import com.twitter.product_mixer.core.model.common.identifier.GateIdentifier
|
|
import com.twitter.product_mixer.core.pipeline.PipelineQuery
|
|
import com.twitter.stitch.Stitch
|
|
|
|
/**
|
|
* Gate that fetches the request context from the device context and
|
|
* continues if the request context does not match any of the specified ones.
|
|
*
|
|
* If no input request context is specified, the gate continues
|
|
*/
|
|
case class RequestContextNotGate(requestContexts: Seq[RequestContext.Value])
|
|
extends Gate[PipelineQuery with HasDeviceContext] {
|
|
|
|
override val identifier: GateIdentifier = GateIdentifier("RequestContextNot")
|
|
|
|
override def shouldContinue(query: PipelineQuery with HasDeviceContext): Stitch[Boolean] =
|
|
Stitch.value(
|
|
!requestContexts.exists(query.deviceContext.flatMap(_.requestContextValue).contains))
|
|
}
|