diff options
| author | dumpfmprod <dumpfmprod@ubuntu.(none)> | 2011-04-19 10:03:59 -0400 |
|---|---|---|
| committer | dumpfmprod <dumpfmprod@ubuntu.(none)> | 2011-04-19 10:03:59 -0400 |
| commit | a756ba2948418acc44f46312fa4148694d7e8e48 (patch) | |
| tree | 7e50b9c35159bb2efaaeeedffa427311b3f0535b /src | |
| parent | f40c5375ba7ce15a78188e21c9f2da63145d4b26 (diff) | |
| parent | 0a4b3ff7a6163e43230418433f4c67fbb15d8621 (diff) | |
Merge branch 'master' of /pichat/repo
Diffstat (limited to 'src')
| -rw-r--r-- | src/site.clj | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/site.clj b/src/site.clj index b6c8882..6668fc7 100644 --- a/src/site.clj +++ b/src/site.clj @@ -22,6 +22,7 @@ email fame message + jedis utils cookie-login session-sweeper @@ -200,6 +201,21 @@ (def earliest-daily-hall (parse-yyyymmdd-date "20100409")) +(defn hall-score [msg-id] + (first (do-select ["select count(*) from tags where message_id = ?" msg-id]))) + +(def frontpage-posts-path "docs/frontpage_msgs.txt") +(def frontpage-posts-agent + (scheduled-agent (fn [] + (try + (let [msg-ids (re-seq #"\w+" + (slurp frontpage-posts-path)) + msgs (datalayer/fetch-messages-by-id (shuffle msg-ids))] + (for [m msgs] + (assoc m :score (hall-score (:message_id m))))) + (catch Exception e (println e) []))) + 12000 + nil)) (defn front-page ([session] (front-page session (format-yyyymmdd (Date.)))) ([session dt-str] @@ -209,7 +225,9 @@ (.after cur-date today) (redirect-to "/") :else (let [st (fetch-template "frontpage" session) dumps (map process-message-for-output - (fetch-redis-daily-hall cur-date 0 20 (:user_id session)))] + (if (:nick session) + (fetch-redis-daily-hall cur-date 0 20 (:user_id session)) + (poll frontpage-posts-agent)))] (.setAttribute st "dumps" dumps) (if-not (.after next-date today) (.setAttribute st "next_date" (format-yyyymmdd next-date))) @@ -1393,6 +1411,7 @@ WHERE user_id IN (def server (start-server (options :port))) (start! active-mutes) +(start! frontpage-posts-agent) (start-user-flusher!) (start-session-pruner!) |
