<commit_before>(ns imago.user
  (:require-macros
   [cljs.core.async.macros :refer [go go-loop]])
  (:require
   [imago.config :as config]
   [thi.ng.cljs.async :as async]
   [thi.ng.cljs.log :refer [debug info warn]]
   [thi.ng.cljs.route :as route]
   [thi.ng.cljs.utils :as utils]
   [thi.ng.cljs.dom :as dom]
   [thi.ng.cljs.io :as io]
   [cljs.core.async :refer [<! timeout]]))

(defn show-template
  [state]
  (let [user (:user @state)
        uname (or (:name user) (:user-name user))]
    (->> (:app-root config/app)
         (dom/clear!)
         (dom/create-dom!
          [:div.jumbotron
           [:h1 (str "Welcome back, " uname)]
           [:p "Here're your collections..."]]))))

(defn show-collections
  [state colls]
  (let [user (-> @state :user :user-name)]
    (->> (:app-root config/app)
         (dom/create-dom!
          [:div
           (for [{:keys [id title thumb]} colls]
             [:div.row
              [:div.col-xs-2 [:img {:src thumb}]]
              [:div.col-xs-6 [:a {:href (str "#/collections/" id)} [:h2 title]]]])]))))

(defn load-collections
  [state]
  (io/request
   :uri     (config/api-route :user-collections (-> @state :user :user-name))
   :method  :get
   :edn?    true
   :success (fn [status body]
              (info :success-response status body)
              (show-collections state (:body body)))
   :error   (fn [status body]
              (warn :error-response status body)
              (async/publish bus :io-fail (:body body)))))

(defn init
  [bus]
  (let [init (async/subscribe bus :init-user)]
    (debug :init-user)<commit_msg>add dummy new coll button on user page<commit_after>(ns imago.user
  (:require-macros
   [cljs.core.async.macros :refer [go go-loop]])
  (:require
   [imago.config :as config]
   [thi.ng.cljs.async :as async]
   [thi.ng.cljs.log :refer [debug info warn]]
   [thi.ng.cljs.route :as route]
   [thi.ng.cljs.utils :as utils]
   [thi.ng.cljs.dom :as dom]
   [thi.ng.cljs.io :as io]
   [cljs.core.async :refer [<! timeout]]))

(defn show-template
  [state]
  (let [user (:user @state)
        uname (or (:name user) (:user-name user))]
    (->> (:app-root config/app)
         (dom/clear!)
         (dom/create-dom!
          [:div.jumbotron
           [:h1 (str "Welcome back, " uname)]
           [:p "Here're your collections..."]
           [:p [:button.btn.btn-primary.btn-lg
                {:events []}
                [:span.glyphicon.glyphicon-plus] " New collection"]]]))))

(defn show-collections
  [state colls]
  (let [user (-> @state :user :user-name)]
    (->> (:app-root config/app)
         (dom/create-dom!
          [:div
           (for [{:keys [id title thumb]} colls]
             [:div.row
              [:div.col-xs-2 [:img {:src thumb}]]
              [:div.col-xs-6 [:a {:href (str "#/collections/" id)} [:h2 title]]]])]))))

(defn load-collections
  [state]
  (io/request
   :uri     (config/api-route :user-collections (-> @state :user :user-name))
   :method  :get
   :edn?    true
   :success (fn [status body]
              (info :success-response status body)
              (show-collections state (:body body)))
   :error   (fn [status body]
              (warn :error-response status body)
              (async/publish bus :io-fail (:body body)))))

(defn init
  [bus]
  (let [init (async/subscribe bus :init-user)]
    (debug :init-user)
{'fraction_non_alphanumeric': 0.1802498512790006, 'fraction_numerical': 0.002379535990481856, 'mean_word_length': 2.205910390848427, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7187367', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1201, 'n_words': 296}