diff options
| -rw-r--r-- | src/redisload.clj | 17 | ||||
| -rw-r--r-- | src/site.clj | 2 | ||||
| -rw-r--r-- | template/log_dump.st | 2 |
3 files changed, 13 insertions, 8 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 diff --git a/src/site.clj b/src/site.clj index 43e7f9a..f487734 100644 --- a/src/site.clj +++ b/src/site.clj @@ -194,7 +194,7 @@ (defn front-page [session] (let [st (fetch-template "frontpage" session) - date-str (format-yyyymmdd (Date.)) + date-str "20100503";(format-yyyymmdd (Date.)) dumps (map process-message-for-output (fetch-redis-daily-hall date-str 0 100))] (.setAttribute st "dumps" dumps) diff --git a/template/log_dump.st b/template/log_dump.st index 60080ad..1cf3145 100644 --- a/template/log_dump.st +++ b/template/log_dump.st @@ -4,7 +4,7 @@ $else$ <div class="logged-dump dump $if(dump.favorited)$favorite$endif$" id="message-$dump.message_id$" nick="$dump.nick$"> $endif$ - +<div><a href="/p/$dump.nick$/$dump.message_id$">$dump.message_id$</a></div> $dump.created_on$ -- by <a href="/$dump.nick$"><b>$dump.nick$</b></a>$if(dump.score)$ <span>$dump.score$</span><img src="$domain$/static/img/thumbs/heartfavedsm.gif" />$endif$ <div class="content" data-category="posts">$dump.content$</div> <hr /> |
