Skip to content
Browse files

イベントがAtndでクエリが空の場合、検索条件に本日・明日・明後日を追加

  • Loading branch information...
1 parent 3cbab2c commit 89c7d665ee40f7d3b8d9c6239ac7b5838c19f4f4 @hiroaqii committed
Showing with 7 additions and 5 deletions.
  1. +7 −5 src/eventsearch/api.clj
View
12 src/eventsearch/api.clj
@@ -4,7 +4,7 @@
(def events {"atnd" {:url "http://api.atnd.org/events/?format=json&count=100&" :key-param "keyword"}
"zusaar" {:url "http://www.zusaar.com/api/event/?count=50&" :key-param "keyword"}
- "partake" {:url "http://partake.in/api/event/search?sortOrder=deadline-r&maxNum=50&beforeDeadlineOnly=false&" :key-param "query"}
+ "partake" {:url "http://partake.in/api/event/search?sortOrder=createdAt&maxNum=50&beforeDeadlineOnly=false&" :key-param "query"}
"doorkeeper" {:url "http://api.doorkeeper.jp/events.json?" :key-param "q"}
})
@@ -15,16 +15,18 @@
(interpose ",")
(apply str)))
-(defn gen-url [k t]
+(defn gen-url [k t d]
(let [event (events t)
url (:url event)]
(if (empty? k)
- url
+ (if (= t "atnd")
+ (str url "ymd=" d) ;;atndで検索クエリが空の場合、本日・明日・明後日の日付を条件に追加する。
+ url)
(str url (:key-param event) "=" (convert-query k)))))
(defn search
- ([{k :keyword t :type} ]
- (try (:body (client/get (gen-url k t)))
+ ([{k :keyword t :type d :date} ]
+ (try (:body (client/get (gen-url k t d)))
(catch Exception e "{\"error\": \"\"}"))))

0 comments on commit 89c7d66

Please sign in to comment.
Something went wrong with that request. Please try again.