[back/perf] change api format
This commit is contained in:
parent
319b875e33
commit
36112c3195
1 changed files with 14 additions and 14 deletions
|
@ -152,31 +152,31 @@
|
||||||
[question-id next]
|
[question-id next]
|
||||||
(let [cursor (last (re-find #"cursor=(.*?)&" next))
|
(let [cursor (last (re-find #"cursor=(.*?)&" next))
|
||||||
session-id (last (re-find #"session_id=(.*?)(?:&|$)" next))]
|
session-id (last (re-find #"session_id=(.*?)(?:&|$)" next))]
|
||||||
(str/join ["/api/hq/"
|
|
||||||
question-id
|
{"question_id" question-id
|
||||||
"?cursor="
|
"cursor" cursor
|
||||||
cursor
|
"session_id" session-id}
|
||||||
"&session_id="
|
))
|
||||||
session-id])))
|
|
||||||
|
|
||||||
(defn process-api-paging
|
(defn process-api-paging
|
||||||
[question-id docs]
|
[question-id docs]
|
||||||
(let [next (get docs "next")]
|
(let [next (get docs "next")]
|
||||||
{:paging {"page" (get docs "page")
|
{:paging (merge
|
||||||
"is_end" (get docs "is_end")
|
{"page" (get docs "page")
|
||||||
"next" (build-paging-next question-id next)}}))
|
"is_end" (get docs "is_end")}
|
||||||
|
(build-paging-next question-id next))}))
|
||||||
|
|
||||||
(defn process-json-paging
|
(defn process-json-paging
|
||||||
[question-id docs]
|
[question-id docs]
|
||||||
(let [answers (val (first (get docs "answers")))]
|
(let [answers (val (first (get docs "answers")))]
|
||||||
(if (< (count (get answers "ids")) 5)
|
(if (< (count (get answers "ids")) 5)
|
||||||
{:paging {"page" nil
|
{:paging {"page" nil
|
||||||
"is_end" true
|
"is_end" true}}
|
||||||
"next" nil}}
|
|
||||||
(let [next_url (get answers "next")]
|
(let [next_url (get answers "next")]
|
||||||
{:paging {"page" nil
|
{:paging (merge
|
||||||
"is_end" false
|
{"page" nil
|
||||||
"next" (build-paging-next question-id next_url)}}))))
|
"is_end" false}
|
||||||
|
(build-paging-next question-id next_url))}))))
|
||||||
|
|
||||||
(defn fetch-hu-question
|
(defn fetch-hu-question
|
||||||
[request params]
|
[request params]
|
||||||
|
|
Loading…
Reference in a new issue