     (let [operationStart (System/currentTimeMillis)]
       (do
         (println "najbardziej popularny temat w maju 2013")
-
+        (def dateBegin (. (t/date-time 2013 5) getMillis))
+        (def dateEnd (. (t/date-time 2013 6) getMillis))
+        (def threadHandles (HGQuery$hg/findAll @database (HGQuery$hg/type ForumThread)))
+        (def threadPostsCounts (map (fn [threadHandle] (count (filter (fn [date] (and (>= date dateBegin) (< date dateEnd))) (map (fn [threadPostLink] (. threadPostLink getValue)) (HGQuery$hg/getAll @database (HGQuery$hg/and (into-array HGQueryCondition [(HGQuery$hg/type Long) (HGQuery$hg/incident threadHandle)]))))))) threadHandles))
+        (def mostPopularThread (reduce (fn [x y] (if (> (last x) (last y)) x y)) (map vector threadHandles threadPostsCounts)))
+        (println (. (. @database get (first mostPopularThread)) getTitle) (last mostPopularThread))
         (println (string/join " " ["Operation took" (String/valueOf (/ (- (System/currentTimeMillis) operationStart) 1000.0)) "seconds"]))
         )
       )

              ;(. @database add (HGPlainLink. (into-array HGHandle [threadHandle userHandle postHandle])))
              (HGQuery$hg/addUnique @database (HGRel. (into-array HGHandle [userHandle threadHandle])) userThreadRelType (HGQuery$hg/link (into-array HGHandle [userHandle threadHandle])))
              (. @database add (HGRel. (into-array HGHandle [userHandle postHandle])) userPostRelType)
              (. @database add (HGRel. (into-array HGHandle [threadHandle postHandle])) threadPostRelType)

              (def saveTime (+ saveTime (- (System/currentTimeMillis) saveStart)))
              )

        ;(def posts (HGQuery$hg/getAll @database (HGQuery$hg/type Post)))
        ;(println (count (filter (fn [post] (if (re-find #"Frodo" (. post getContent)) true false)) posts)))
        (println (string/join " " ["Operation took" (String/valueOf (/ (- (System/currentTimeMillis) operationStart) 1000.0)) "seconds"]))
        (println)
        )
      )

    (let [operationStart (System/currentTimeMillis)]
      (do
