diff options
| author | Scott Ostler <scottbot9000@gmail.com> | 2011-02-15 10:57:43 -0500 |
|---|---|---|
| committer | Scott Ostler <scottbot9000@gmail.com> | 2011-02-15 10:57:43 -0500 |
| commit | 460da48afab901cc4ae784e6b049fc52dea3b2ce (patch) | |
| tree | dfc1d8bc43a0bca083c9abe8d8d5b7d280b2a3d6 /src/redisload.clj | |
| parent | c07c3220ee956e02de5ea54683780e765fdb3b6c (diff) | |
sostler commit frontpage wip
Diffstat (limited to 'src/redisload.clj')
| -rw-r--r-- | src/redisload.clj | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/redisload.clj b/src/redisload.clj index d05d9ed..26888e3 100644 --- a/src/redisload.clj +++ b/src/redisload.clj @@ -134,29 +134,34 @@ WHERE (if (.after cur max) acc (recur (conj acc (cal-to-date next)) next)))))) - + + (defn get-top-posts [dt limit] (do-select [" SELECT m.message_id as message_id, count(*) as score - FROM messages m, tags t - WHERE m.message_id = t.message_id + FROM messages m, tags t, rooms r + WHERE m.message_id = t.message_id and m.room_id = r.room_id + AND m.user_id != t.user_id AND m.created_on::date = ?::date + AND m.is_image + AND r.admin_only = false GROUP BY m.message_id ORDER BY score DESC LIMIT ?" (date-to-sql dt) limit])) (defn build-daily-hall [dt] - (let [top-posts (get-top-posts dt 200) + (let [top-posts (get-top-posts dt 20) datekey (redis-daily-hall-key (format-yyyymmdd dt))] (println (count top-posts) "posts for" datekey) (redis/with-server redis-server (redis/atomically (redis/del datekey) (doseq [m top-posts] - (redis/zadd datekey (int (:score m)) (int (:message_id m)))))))) + (println (:message_id m) (:score m)) + (redis/zadd datekey (:score m) (:message_id m))))))) (defn build-all-daily-hall [] (doseq [dt (get-fav-date-range)] (build-daily-hall dt))) -(build-all-daily-hall)
\ No newline at end of file +(build-daily-hall (parse-yyyy-mm-dd-date "2010-05-03"))
\ No newline at end of file |
