incubator-esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vdic...@apache.org
Subject svn commit: r804820 - in /incubator/esme/trunk/server/src/main: scala/bootstrap/liftweb/Boot.scala scala/org/apache/esme/model/UrlStore.scala scala/org/apache/esme/snippet/UserSnip.scala webapp/templates-hidden/message.html
Date Sun, 16 Aug 2009 23:49:50 GMT
Author: vdichev
Date: Sun Aug 16 23:49:49 2009
New Revision: 804820

URL: http://svn.apache.org/viewvc?rev=804820&view=rev
Log:
Snippet for most clicked links.

Modified:
    incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/UrlStore.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/snippet/UserSnip.scala
    incubator/esme/trunk/server/src/main/webapp/templates-hidden/message.html

Modified: incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala?rev=804820&r1=804819&r2=804820&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala Sun Aug 16 23:49:49
2009
@@ -148,6 +148,7 @@
     ScalaInterpreter.touch
     
     PopStatsActor ! PopStatsActor.StartStats(ResendStat, 1 week, 1 hour)
+    PopStatsActor ! PopStatsActor.StartStats(LinkClickedStat, 1 week, 1 hour)
 
     Action.findAll(By(Action.disabled, false), By(Action.removed, false)).foreach {
       _.startActors

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/UrlStore.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/UrlStore.scala?rev=804820&r1=804819&r2=804820&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/UrlStore.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/UrlStore.scala Sun Aug
16 23:49:49 2009
@@ -26,6 +26,9 @@
 import util._
 import http._
 
+import org.apache.esme.actor.PopStatsActor
+import org.apache.esme.actor.LinkClickedStat
+
 object UrlStore extends UrlStore with LongKeyedMetaMapper[UrlStore] {
   def redirectizer: LiftRules.DispatchPF = {
     case Req("u" :: id :: Nil, "", GetRequest) =>
@@ -34,7 +37,10 @@
 
   private def serve(id: String)(): Box[LiftResponse] = 
   for (url <- find(By(uniqueId, id)))
-  yield RedirectResponse(url.url)
+  yield {
+    PopStatsActor ! PopStatsActor.IncrStats(LinkClickedStat, url.id)
+    RedirectResponse(url.url)
+  }
 
   def make(in: String): UrlStore = {
     find(By(url, in)) match {

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/snippet/UserSnip.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/snippet/UserSnip.scala?rev=804820&r1=804819&r2=804820&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/snippet/UserSnip.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/snippet/UserSnip.scala Sun
Aug 16 23:49:49 2009
@@ -92,7 +92,8 @@
       "loggedIn" -> loggedInFilter _,
       "accessPools" -> accessPools _,
       "resendScript" -> resendScript _,
-      "popular" -> popular _)
+      "popular" -> popular _,
+      "links" -> links _)
 
   def loggedInFilter(in: NodeSeq): NodeSeq = {
     val lookFor = if (User.loggedIn_?) "in" else "out"
@@ -199,4 +200,30 @@
       }
     }
   </xml:group>
+
+  def links(in: NodeSeq): NodeSeq = 
+  <xml:group>
+    {PopStatsActor !? PopStatsActor.TopStats(LinkClickedStat, 5, 1 week) match {
+        case l: List[Tuple2[Long,Int]] =>
+          <table>
+            <thead>
+              <tr> <th>Clicked</th> <th>Link</th> </tr>
+            </thead>
+            <tbody>
+            {
+              l.map{ stat =>
+                val (linkId, freq) = stat
+                (for (u <- UrlStore.find(linkId)) yield {
+                  <tr>
+                    <td>{freq}</td> <td>{u.url.is}</td>
+                  </tr>
+                }).getOrElse(<br/>)
+              }
+            }
+            </tbody>
+          </table>
+        case _ => <br/>
+      }
+    }
+  </xml:group>
 }

Modified: incubator/esme/trunk/server/src/main/webapp/templates-hidden/message.html
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/webapp/templates-hidden/message.html?rev=804820&r1=804819&r2=804820&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/webapp/templates-hidden/message.html (original)
+++ incubator/esme/trunk/server/src/main/webapp/templates-hidden/message.html Sun Aug 16 23:49:49
2009
@@ -314,6 +314,11 @@
                   <lift:UserSnip.popular/>
                 </div>
 
+                <div class="b-stats">
+                  <p id="stats-para">Popular links</p>
+                  <lift:UserSnip.links/>
+                </div>
+
                 <lift:ignore>
                   <div class="bugs">
                     <form action="/user_view/search"



Mime
View raw message