<commit_before>(ns frontend.controllers.post-navigation
  (:require [cljs.core.async :as async :refer [>! <! alts! chan sliding-buffer put! close!]]
            [clojure.string :as string]
            [frontend.utils :as utils :refer [mlog merror]]
            [frontend.pusher :as pusher]
            [goog.string :as gstring]
            [goog.string.format]))

(defn set-page-title! [& [title]]
  (set! (.-title js/document) (if title
                                (str title  " - CircleCI")
                                "CircleCI")))

(defmulti post-navigated-to!
  (fn [history-imp to args previous-state current-state] to))

(defmethod post-navigated-to! :default
  [history-imp to args previous-state current-state]
  (mlog "No post-nav for: " to))

(defmethod post-navigated-to! :navigate!
  [history-imp to path previous-state current-state]
  (.setToken history-imp path))

(defmethod post-navigated-to! :dashboard
  [history-imp to args previous-state current-state]
  (let [api-ch (get-in current-state [:comms :api])]
    (utils/ajax :get "/api/v1/projects" :projects api-ch)
    (when-let [builds-url (cond (empty? args) "/api/v1/recent-builds"
                                (:branch args) (gstring/format "/api/v1/project/%s/%s/tree/%s"
                                                               (:org args) (:repo args) (:branch args))
                                (:repo args) (gstring/format "/api/v1/project/%s/%s"
                                                             (:org args) (:repo args))
                                (:org args) (gstring/format "/api/v1/organization/%s"
                                                            (:org args))
                                :else (merror "unknown path for %s" args))]
      (utils/ajax :get builds-url :recent-builds api-ch)))
  (set-page-title!))
<commit_msg>strip leading slash before setting token<commit_after>(ns frontend.controllers.post-navigation
  (:require [cljs.core.async :as async :refer [>! <! alts! chan sliding-buffer put! close!]]
            [clojure.string :as string]
            [frontend.utils :as utils :refer [mlog merror]]
            [frontend.pusher :as pusher]
            [goog.string :as gstring]
            [goog.string.format]))

(defn set-page-title! [& [title]]
  (set! (.-title js/document) (if title
                                (str title  " - CircleCI")
                                "CircleCI")))

(defmulti post-navigated-to!
  (fn [history-imp to args previous-state current-state] to))

(defmethod post-navigated-to! :default
  [history-imp to args previous-state current-state]
  (mlog "No post-nav for: " to))

(defmethod post-navigated-to! :navigate!
  [history-imp to path previous-state current-state]
  (let [path (if (= \/ (first path))
               (subs path 1)
               path)]
    (.setToken history-imp path)))

(defmethod post-navigated-to! :dashboard
  [history-imp to args previous-state current-state]
  (let [api-ch (get-in current-state [:comms :api])]
    (utils/ajax :get "/api/v1/projects" :projects api-ch)
    (when-let [builds-url (cond (empty? args) "/api/v1/recent-builds"
                                (:branch args) (gstring/format "/api/v1/project/%s/%s/tree/%s"
                                                               (:org args) (:repo args) (:branch args))
                                (:repo args) (gstring/format "/api/v1/project/%s/%s"
                                                             (:org args) (:repo args))
                                (:org args) (gstring/format "/api/v1/organization/%s"
                                                            (:org args))
                                :else (merror "unknown path for %s" args))]
      (utils/ajax :get builds-url :recent-builds api-ch)))
  (set-page-title!))

{'fraction_non_alphanumeric': 0.13768870380010412, 'fraction_numerical': 0.0028630921395106715, 'mean_word_length': 1.6558396682791983, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1775937', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1110, 'n_words': 284}