summaryrefslogtreecommitdiff
path: root/src/fame.clj
blob: 0732992a22019b5eb92f907ded8487006d1d1207 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(ns fame
  (:use scheduled-agent
	utils))

; should probably cache this to disk somewhere
(def hall-of-fame-update-frequency (* 5 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))