e367ba493db4fdaf Release Indicator - relevant only for Stop packets
authorTomas Zeman <tzeman@volny.cz>
Thu, 14 Apr 2011 15:35:44 +0200
changeset 16 930d0b9e5169
parent 15 2637add66b57
child 17 edb9bd4db3bb
e367ba493db4fdaf Release Indicator - relevant only for Stop packets
src/main/scala/radview/model/Cdr.scala
src/main/scala/radview/snippet/SessionSnippet.scala
--- a/src/main/scala/radview/model/Cdr.scala	Tue Apr 12 19:16:13 2011 +0200
+++ b/src/main/scala/radview/model/Cdr.scala	Thu Apr 14 15:35:44 2011 +0200
@@ -69,7 +69,7 @@
     case xs =>
       val cdr1 = findAllByPreparedStatement { sc =>
         val selectS = List(sid.dbColumnName, diff(inBytes), diff(outBytes),
-          min(radacctid), max(ts))
+          max(radacctid), min(ts))
         val sql = String.format(
           "SELECT %s FROM %s WHERE %s IN (%s) GROUP BY %s",
           selectS.mkString(","), dbTableName, sid.dbColumnName,
@@ -85,8 +85,7 @@
         c1 <- cdr1
         c2 <- tsMap.get(c1.sid.is)
       } yield {
-        CdrSession(c1.sid, c2.ts, c1.ts, c1.inBytes, c1.outBytes, c2.cell,
-          c2.callingNo)
+        CdrSession(c1.sid, c1.ts, c2.ts, c1.inBytes, c1.outBytes, c2)
       }
   }
 }
@@ -174,7 +173,10 @@
 
   object releaseInd extends MappedIntColName(this, "3GPP2_Release_Indicator",
     "3GPP2 Release Indicator") {
-    override def asHtml = Text(ReleaseIndicator.lookup(is).openOr(is.toString))
+    override def asHtml = Text(statusType.is.toLowerCase match {
+      case "stop" => ReleaseIndicator.lookup(is).openOr(is.toString)
+      case _ => ""
+    })
   }
 
   object activeTime extends MappedIntColName(this, "3GPP2_Active_Time",
@@ -191,9 +193,9 @@
 }
 
 case class CdrSession(sid: String, start: Date, end: Date, inBytes: Long,
-  outBytes: Long, cellId: String, callingNo: Long) {
+  outBytes: Long, stop: Cdr) {
 
-  def cell: Box[Cell] = Cell.findByKey(cellId)
+  def cell: Box[Cell] = stop.cell.obj
 }
 
 // vim: set ts=2 sw=2 et:
--- a/src/main/scala/radview/snippet/SessionSnippet.scala	Tue Apr 12 19:16:13 2011 +0200
+++ b/src/main/scala/radview/snippet/SessionSnippet.scala	Thu Apr 14 15:35:44 2011 +0200
@@ -87,8 +87,11 @@
     ) map { r: (String, Any) =>
       AttrRow(Text(r._1), Text(r._2.toString))
     }
-    Panel(l1 :+ AttrRow(Text("Cell"), s.cell.map { c =>
-      A(CellSnippet.url(CellView(c)), c.btsName.is) } openOr NodeSeq.Empty))
+    val l2 = s.cell.toList.flatMap { c => List(
+      AttrRow(Text("Cell"), s.stop.cell.asHtml),
+      AttrRow(Text(Cdr.releaseInd.displayName), s.stop.releaseInd.asHtml)
+    )}
+    Panel(l1 ++ l2)
   }
 }
 
@@ -97,7 +100,7 @@
 object CdrSessionTable {
   def apply(l: Iterable[CdrSession]): (NodeSeq => NodeSeq) = {
     val accounts: Map[String, RadCheckSub] = Map() ++
-      (RadCheckSub.byImsi(l.map { _.callingNo.toString }.toList.distinct).
+      (RadCheckSub.byImsi(l.map { _.stop.callingNo.toString }.toList.distinct).
       map { r => (r.imsi.is, r) })
 
     Table[CdrSession](List(
@@ -110,7 +113,7 @@
       Column(Cdr.outBytes.displayName + " [MB]",
         { s: CdrSession => Bytes.mb(s.outBytes) }, "td-right"),
       Column(RadCheckSub.imsi.displayName,
-        { s: CdrSession => accounts.get(s.callingNo.toString).map { r =>
+        { s: CdrSession => accounts.get(s.stop.callingNo.toString).map { r =>
           A(AccountSnippet.url(ViewAccount(r)), r.imsi.asHtml)
         } getOrElse NodeSeq.Empty })
       ), l)