SHARE
TWEET

Untitled

a guest Aug 24th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import GASessionsBounceRateReport.DataRow
  2. import cells.Cell.Data
  3. import cells.customfunctions.{Decoder, Output}
  4.  
  5. import scala.scalajs.js
  6.  
  7. /**
  8.  * Contains the [[DataRow]] information for different kinds of information type. For example, "Current Month" or
  9.  * "Year to Date".
  10.  * @param info map from the information type to the information contents.
  11.  */
  12. final case class GASessionsBounceRateReport(info: Map[String, DataRow]) {
  13.     def row(infoType: String): js.Array[Data] = {
  14.         val theseInfo = info(infoType)
  15.         js.Array(
  16.             infoType,
  17.             theseInfo.sessionsInfo.desktop, theseInfo.sessionsInfo.tablet, theseInfo.sessionsInfo.mobile,
  18.             theseInfo.sessionsInfo.total,
  19.             theseInfo.bounceRateInto.desktop, theseInfo.bounceRateInto.tablet, theseInfo.bounceRateInto.mobile,
  20.             theseInfo.bounceRateInto.global
  21.         )
  22.     }
  23. }
  24.  
  25. object GASessionsBounceRateReport {
  26.  
  27.     final case class SessionsInfo(mobile: Int, desktop: Int, tablet: Int) {
  28.         def total: Int = mobile + desktop + tablet
  29.     }
  30.  
  31.     /** We include the global value here since it has to be a weighted average and the info aren't there. */
  32.     final case class BounceRateInfo(mobile: Double, desktop: Double, tablet: Double, global: Double)
  33.  
  34.     final case class DataRow(sessionsInfo: SessionsInfo, bounceRateInto: BounceRateInfo)
  35.  
  36.     implicit final val gaReportDecoder: Decoder[GASessionsBounceRateReport] = (u: GASessionsBounceRateReport) => js.Array(
  37.         js.Array("", "Sessions", "", "", "", "Bounce Rate"),
  38.         js.Array("", "Desktop", "Tablet", "Mobile", "Total", "Desktop", "Tablet", "Mobile", "Global"),
  39.         u.row("Current Month"),
  40.         u.row("Previous Month"),
  41.         u.row("Year to Date")
  42.     )
  43.  
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top