Skip to content

Instantly share code, notes, and snippets.

@jawsthegame
Created March 1, 2013 19:34
Show Gist options
  • Save jawsthegame/5067138 to your computer and use it in GitHub Desktop.
Save jawsthegame/5067138 to your computer and use it in GitHub Desktop.
object PublisherContext {
def apply(device: Device, network: Network): PublisherContext =
apply(network)
def apply(ntwrk: Network): PublisherContext = apply(ntwrk, None, None)
def apply(ntwrk: Network, index: Option[Int],
ven: Option[Venue]): PublisherContext = {
val gvtData = ven.flatMap(_.gvtData).getOrElse(ntwrk.gvtData)
new PublisherContext {
val network = ntwrk
val cpmFloorCents = ven.flatMap(v =>
if (v.cpmCents == Some(0)) None else v.cpmCents)
.getOrElse(ntwrk.cpmCents)
val impressionsPerSecond = gvtData.gvt.toDouble / gvtData.gvtSeconds
val dwellTimeSeconds = gvtData.dwellTime
val signageProviderId = ntwrk.signageProviderId
val geoindex = index
val venue = ven
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment