summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/site.clj29
-rw-r--r--src/tags.clj6
2 files changed, 33 insertions, 2 deletions
diff --git a/src/site.clj b/src/site.clj
index c25a18d..c9b484b 100644
--- a/src/site.clj
+++ b/src/site.clj
@@ -848,6 +848,28 @@ WHERE u.user_id = ANY(?)"
(log session (lookup-room room-key) offset params)
(resp-error "UNKNOWN_ROOM"))))
+;; Hiscore test... redis test...
+
+(defn redis-ids-test [period]
+ (let [reddis-server {:host "127.0.0.1" :port 6379 :db 0}
+ ids (redis/with-server reddis-server
+ (redis/zrevrange (str "hiscore." period) 0 20))
+ ids (map maybe-parse-int ids)]
+ ids))
+
+(defn hiscore-test [session params period]
+ (let [st (fetch-template "hiscore_test" session)
+ dumps (tags/fetch-dumps-by-ids (redis-ids-test period))
+ dumps (map tags/add-favorited-flag dumps (repeat session))
+ dumps (map tags/add-fav-count dumps)
+ dumps (reverse (sort-by :favcount dumps))
+ dumps (map tags/remove-tags-for-output dumps)
+ dumps (map process-message-for-output dumps)]
+ (.setAttribute st "dumps" dumps)
+ (.toString st)))
+
+
+
;; Altars
(defn altar-log [session params]
@@ -1304,6 +1326,13 @@ WHERE u.user_id = ANY(?)"
(altar-log session params)
(redirect-to (str "/" (params :id) "/altars")))) ;; redirect /altars/timb to /timb/altars
+ ;; testing
+ (GET "/test/hiscores" (hiscore-test session params "week"))
+ (GET "/test/hiscores/week" (hiscore-test session params "week"))
+ (GET "/test/hiscores/month" (hiscore-test session params "month"))
+
+
+
;; Events
(GET "/event" (current-event session))
diff --git a/src/tags.clj b/src/tags.clj
index 01414e9..835591a 100644
--- a/src/tags.clj
+++ b/src/tags.clj
@@ -64,6 +64,9 @@
(assoc row :favorited true)
row))
+(defn add-fav-count [row]
+ (assoc row :favcount (count ((row :tags) "favorite"))))
+
(def user-fav-query "
SELECT v
FROM UNNEST(?) as v
@@ -259,8 +262,7 @@ WHERE EXISTS
WHERE
m.message_id IN (" (str-join ", " (take num-messages (repeat "?"))) ") "
" AND m.user_id = u.user_id
- AND r.room_id = m.room_id
- ORDER BY m.message_id DESC"))
+ AND r.room_id = m.room_id"))
(defnk fetch-dumps-by-tag-query [:image-only true :message-user-id false :tag-user-id false :with-tags true :include-vip false] (str