<commit_before>(ns kixi.hecuba.tabs.profiles
  (:require [om.core :as om :include-macros true]
            [sablono.core :as html :refer-macros [html]]
            [kixi.hecuba.bootstrap :as bs]))

(enable-console-print!)

(defn get-profiles [selected-property-id data]
  (->>  data
        :properties
        :data
        (filter #(= (:id %) selected-property-id))
        first
        :profiles))

(defn displayable? [d]
  (and d
       (not (re-find #"\w" d))))

(defn display [m k]
  (if-let [d (displayable? (get m k))]
    d
    "N/A"))

(defn occupancy-row [profiles owner]
  (reify
    om/IRenderState
    (render-state [_ state]
      (println "Number of profiles: " (count profiles))
      (html
       [:div.col-md-12
        (for [profile profiles]
          (let [profile_data (:profile_data profile)]
            [:div.col-md-4
             (bs/panel
              "Occupancy"
              [:dl
               [:dt "Occupancy Under 18"] [:dd (display profile_data :occupancy_under_18)]
               [:dt "Occupancy 18 To 60"] [:dd (display profile_data :occupancy_18_to_60)]
               [:dt "Occupancy Over 60"] [:dd (display profile_data :occupancy_over_60)]
               [:dt "Occupant Change"] [:dd (display profile_data :occupant_change)]])]))]))))

(defn profile-rows [profiles owner]
  (reify
    om/IRenderState
    (render-state [_ state]
      (html
       [:div.col-md-12
        (om/build occupancy-row profiles)
        ;; (om/build measurements profiles)
        ;; (om/build energy profiles)
        ;; (om/build efficiency profiles)
        ;; (om/build flats profiles)
        ;; (om/build firepalces profiles)
        ;; (om/build glazing profiles)
        ;; (om/build issues profiles)
        ;; (om/build sap-results profiles)
        ;; (om/build documents profiles)
        ;; (om/build co-heating profiles)
        ;; (om/build air-tightness profiles)
        ;; (om/build conservatories profiles)
        ;; (om/build extensions profiles)
        ;; (om/build heating-systems profiles)
        ;; (om/build hot-water-systems profiles)
        ;; (om/build storeys profiles)
        ;; (om/build walls profiles)
        ;; (om/build roofs profiles)
        ;; (om/build window-types profiles)
        ;; (om/build door-types profiles)
        ;; (om/build floors profiles)
        ;; (om/build roof-rooms profiles)
        ;; (om/build low-energy-lights profiles)
        ;; (om/build ventilation-systems profiles)
        ;; (om/build photovoltaic-panels profiles)
        ;; (om/build solar-thermal-panels profiles)<commit_msg>Added header row for profiles.<commit_after>(ns kixi.hecuba.tabs.profiles
  (:require [om.core :as om :include-macros true]
            [sablono.core :as html :refer-macros [html]]
            [cljs-time.coerce :as tc]
            [cljs-time.format :as tf]
            [kixi.hecuba.bootstrap :as bs]))

(enable-console-print!)

(defn get-profiles [selected-property-id data]
  (->>  data
        :properties
        :data
        (filter #(= (:id %) selected-property-id))
        first
        :profiles))

(defn format-time-inst [t format]
  (if (nil? t)
    "Undated"
    (let [date (tc/from-date t)]
      (tf/unparse (tf/formatter format) date))))

(defn displayable? [d]
  (and d
       (not (re-find #"\w" d))))

(defn display [m k]
  (if-let [d (displayable? (get m k))]
    d
    "N/A"))

(defn profile-column-width []
  "col-md-3")

(defn header-row [profiles owner]
  (reify
    om/IRenderState
    (render-state [_ state]
      (html
       [:div.col-md-12
        (for [profile profiles]
          (let [category (get-in profile [:profile_data :category] "Intervention")
                timestamp (format-time-inst  (:timestamp profile) "yyyy-MM-dd")]
            [:div {:class (profile-column-width)}
             [:h3.text-center category [:br ] [:small timestamp]]]))]))))

(defn occupancy-row [profiles owner]
  (reify
    om/IRenderState
    (render-state [_ state]
      (println "Number of profiles: " (count profiles))
      (html
       [:div.col-md-12
        (for [profile profiles]
          (let [profile_data (:profile_data profile)]
            [:div {:class (profile-column-width)}
             (bs/panel
              "Occupancy"
              [:dl
               [:dt "Occupancy Under 18"] [:dd (display profile_data :occupancy_under_18)]
               [:dt "Occupancy 18 To 60"] [:dd (display profile_data :occupancy_18_to_60)]
               [:dt "Occupancy Over 60"] [:dd (display profile_data :occupancy_over_60)]
               [:dt "Occupant Change"] [:dd (display profile_data :occupant_change)]])]))]))))

(defn profile-rows [profiles owner]
  (reify
    om/IRenderState
    (render-state [_ state]
      (html
       [:div.col-md-12
        (om/build header-row profiles)
        (om/build occupancy-row profiles)
        ;; (om/build measurements profiles)
        ;; (om/build energy profiles)
        ;; (om/build efficiency profiles)
        ;; (om/build flats profiles)
        ;; (om/build firepalces profiles)
        ;; (om/build glazing profiles)
        ;; (om/build issues profiles)
        ;; (om/build sap-results profiles)
        ;; (om/build documents profiles)
        ;; (om/build co-heating profiles)
        ;; (om/build air-tightness profiles)
        ;; (om/build conservatories profiles)
        ;; (om/build extensions profiles)
        ;; (om/build heating-systems profiles)
        ;; (om/build hot-water-systems profiles)
        ;; (om/build storeys profiles)
        ;; (om/build walls profiles)
        ;; (om/build roofs profiles)
        ;; (om/build window-types profiles)
        ;; (om/build door-types profiles)
        ;; (om/build floors profiles)
        ;; (om/build roof-rooms profiles)
        ;; (om/build low-energy-lights profiles)
        ;; (om/build ventilation-systems profiles)
        ;; (om/build photovoltaic-panels profiles)
        ;; (om/build solar-thermal-panels profiles)
{'fraction_non_alphanumeric': 0.14120020171457387, 'fraction_numerical': 0.007564296520423601, 'mean_word_length': 2.2231852654387865, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1996942', 'n_tokens_mistral': 1991, 'n_tokens_neox': 1842, 'n_words': 466}