From 36112c319524fc61c9a341e8666f64220e684418 Mon Sep 17 00:00:00 2001 From: SouthFox Date: Tue, 12 Sep 2023 18:59:41 +0800 Subject: [PATCH] [back/perf] change api format --- src/main/backend/handlers.clj | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/backend/handlers.clj b/src/main/backend/handlers.clj index 01d43c6..b6877c8 100644 --- a/src/main/backend/handlers.clj +++ b/src/main/backend/handlers.clj @@ -152,31 +152,31 @@ [question-id next] (let [cursor (last (re-find #"cursor=(.*?)&" next)) session-id (last (re-find #"session_id=(.*?)(?:&|$)" next))] - (str/join ["/api/hq/" - question-id - "?cursor=" - cursor - "&session_id=" - session-id]))) + + {"question_id" question-id + "cursor" cursor + "session_id" session-id} + )) (defn process-api-paging [question-id docs] (let [next (get docs "next")] - {:paging {"page" (get docs "page") - "is_end" (get docs "is_end") - "next" (build-paging-next question-id next)}})) + {:paging (merge + {"page" (get docs "page") + "is_end" (get docs "is_end")} + (build-paging-next question-id next))})) (defn process-json-paging [question-id docs] (let [answers (val (first (get docs "answers")))] (if (< (count (get answers "ids")) 5) {:paging {"page" nil - "is_end" true - "next" nil}} + "is_end" true}} (let [next_url (get answers "next")] - {:paging {"page" nil - "is_end" false - "next" (build-paging-next question-id next_url)}})))) + {:paging (merge + {"page" nil + "is_end" false} + (build-paging-next question-id next_url))})))) (defn fetch-hu-question [request params]