 ;; State
 
 (defonce people-atom (atom []))
-
+(defonce filters (atom ["(.startsWith :Name \"Ma\")"]))
+(def all-profile-keys '(:IsObjectivesAdmin :LaborCategoryID :FirstName :LaborRoleID :OversightPercent :WorkTeamID :BusinessUnitName :MobileNumber :PhotoFileName :IsCandidateAdmin :CanCommunicateClient :UserSystemID :Email :CreatedDate :BillingTargetHoursPerYear :Title :MobileNumberCountryCode :IsClient :IsScheduleConfirmationRulesEnforced :LastName :IsScheduleAdmin :UserName :Extension :TimeZoneName :HomeNumber :IsNotAPerson :UserID :KeyscanUpdated :HasDirectReports :IsAdmin :BusinessUnitID :CountryID :CompanyBusinessUnitID :TimeZoneID :PhotoPath :Name :Roles :CompanyBusinessUnitName :IsWeeklyReviewAdmin :Enabled :TagName :Supervisors :KeyscanStatus :OutOfOfficeReason :Status))
+; (take! (genome/<get-all-active-klickster-profiles) (fn [profiles] (->> (apply merge profiles ) keys prn)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Actions

        (fn [result] result)))


(defn create-filter-fn 
  "creates a filter function thing"
  [keys expr]
  (let [my-user (gensym "user")
        replace-where-appropriate (fn [sym]
                                    (cond
                                      (not (keyword? sym)) sym
                                      (some #{sym} keys) `(~sym ~my-user)
                                      :else sym))]
    (->>
     (read-string expr)
     (walk/postwalk replace-where-appropriate ,,,)
     ((fn [new-expr]
        `(fn [~my-user] ~new-expr)) ,,,))))


(def exp "(.startsWith :Name \"Max\")")
(defn try-filter []
  (= '({:Name "Maximilian"}) 
     (filter
      (create-filter-fn [:Name] exp)
      [{:Name "Bob"} {:Name "Maximilian"}]))
  )

;; Todo:
;; partition-by :KeyscanStatus. Then display and add filters.
;; add a <users-details test data set monday morning
;; partition the users by 200


;; -------------------------

(secretary/defroute "/about" []
  (session/put! :current-page #'about))

(secretary/defroute "/filters" []
  (session/put! :current-page #'Filters))
;; -------------------------
;; History
;; must be called after routes have been defined
