summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fame.clj27
-rw-r--r--src/site.clj11
2 files changed, 36 insertions, 2 deletions
diff --git a/src/fame.clj b/src/fame.clj
new file mode 100644
index 0000000..8f0ae4f
--- /dev/null
+++ b/src/fame.clj
@@ -0,0 +1,27 @@
+(ns fame
+ (:use scheduled-agent
+ utils))
+
+; should probably cache this to disk somewhere
+(def hall-of-fame-update-frequency (* 4 60 60))
+
+(def hall-of-fame-query "
+select m.created_on, m.message_id, m.content, u.nick, u.avatar, r.key, count(*)
+from tags t, messages m, rooms r, users u
+where t.message_id = m.message_id
+and m.user_id = u.user_id
+and m.room_id = r.room_id
+and r.admin_only = false
+group by m.created_on, m.message_id, m.content, u.nick, u.avatar, r.key
+order by count(*) desc
+limit 50
+")
+
+(defn fetch-hall-of-fame []
+ (do-select [hall-of-fame-query]))
+
+
+(def hall-results (scheduled-agent fetch-hall-of-fame
+ hall-of-fame-update-frequency
+ nil))
+ \ No newline at end of file
diff --git a/src/site.clj b/src/site.clj
index 2777efc..6a011c6 100644
--- a/src/site.clj
+++ b/src/site.clj
@@ -17,6 +17,7 @@
admin
compojure
email
+ fame
utils
cookie-login
session-sweeper
@@ -741,7 +742,6 @@ FROM users u
(if (not= offset 0)
(.setAttribute st "prev" (max (dec offset) 0)))
(.setAttribute st "dumps" dumps)
- ;; (.setAttribute st "json_tags" json-tags)
(if (default-room? roomkey)
(.setAttribute st "roomkey" "")
(.setAttribute st "roomkey" (str roomkey ".")))
@@ -1046,6 +1046,11 @@ FROM users u
(.toString st)
(unknown-page)))
+(defn hall-of-fame [session]
+ (let [st (fetch-template "fame" session)]
+ (.setAttribute st "dumps" (map process-message-for-output (poll hall-results)))
+ (.toString st)))
+
;; Compojure Routes
(defn serve-static [dir path]
@@ -1121,6 +1126,8 @@ FROM users u
;; Memes
(GET "/m/:m" (serve-meme session (params :m)))
+
+ (GET "/hall" (hall-of-fame session))
;; Footer pages
(GET "/about_us" (serve-template "about_us" session))
@@ -1217,7 +1224,7 @@ FROM users u
(Thread/sleep 3000)
(start-user-flusher!)
(start-session-pruner!)
-
+(start! hall-results)
(if (= *server-url* "http://dump.fm")
(do (start! feed-downloader)
(start! feed-inserter)))