<commit_before>(ns bmihw.manage
    (:require [reagent.core :as reagent :refer [atom]]
              [reagent.session :as session]
              [secretary.core :as secretary :include-macros true]
              [goog.events :as events]
              [goog.history.EventType :as EventType]
              [ajax.core :refer [GET POST]]
              [bmihw.common :refer [auth fb]]
              [cljsjs.firebase :as firebase])
    (:import goog.History))

(def events (reagent/atom []))

(defn drunk?
  [{drunk "drunk" :as event}]
  (or (nil? drunk) (= drunk "true") drunk))
  

(defn add-event
  [{id :id user "username" target "target-username" keyword "keyword" content "content" :as event}]
  (let [current-user (get-in @auth ["twitter" "username"])]
    (.log js/console (str "Event User: " user ", Current User:" current-user))
    (if (= user current-user)
      (swap! events conj {:id id 
                          :user user 
                          :keyword keyword
                          :target target
                          :drunk (drunk? event)
                          :content content}))))

(defn handle-childsnapshot
  [snapshot]
  (let [key (.key snapshot)
        val (.val snapshot)]
    (if val
      (add-event (merge {:id key} (js->clj val))))))

(.on fb "child_added" handle-childsnapshot)
    
(defn manage-page
  []
  (let [who (get-in auth ["uid"])]
	  [:div [:h4 "Manage Your Insults To Those Deserving Bastards!"]
	   [:table#manage {:style {:width "100%"}}
	    [:tr
	     [:th "Drunk"][:th "Event"][:th "Insult"][:th "Keyword"] [:td who]]
     (for [event @events]
       [:tr 
        [:td (or (and (:drunk event) "Hell Yeah!") "Nope")]
        [:td (:target event)]
        [:td (:content event)]
        [:td (:keyword event)]
        [:td [:input {:type :button :value "Delete"}]]])]]))


(secretary/defroute "/manage" []
  (session/put! :current-page #'manage-page))
<commit_msg>Adding base delete<commit_after>(ns bmihw.manage
    (:require [reagent.core :as reagent :refer [atom]]
              [reagent.session :as session]
              [secretary.core :as secretary :include-macros true]
              [goog.events :as events]
              [goog.history.EventType :as EventType]
              [ajax.core :refer [GET POST]]
              [bmihw.common :refer [auth fb]]
              [cljsjs.firebase :as firebase])
    (:import goog.History))

(def events (reagent/atom []))

(defn drunk?
  [{drunk "drunk" :as event}]
  (or (nil? drunk) (= drunk "true") drunk))
  

(defn add-event
  [{id :id user "username" target "target-username" keyword "keyword" content "content" :as event}]
  (let [current-user (get-in @auth ["twitter" "username"])]
    (.log js/console (str "Event User: " user ", Current User:" current-user))
    #_(if (= user current-user))
       (swap! events conj {:id id 
                           :user user 
                           :keyword keyword
                           :target target
                           :drunk (drunk? event)
                           :content content})));;)

(defn handle-childsnapshot
  [snapshot]
  (let [key (.key snapshot)
        val (.val snapshot)]
    (if val
      (add-event (merge {:id key} (js->clj val))))))

(defn delete-page
  []
  [:div 
   [:p "Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut."]
   [:i "- <NAME>"]])

(defn manage-page
  []
  (let [who (get-in auth ["uid"])]
	  [:div [:h4 "Manage Your Insults To Those Deserving Bastards!"]
	   [:table#manage {:style {:width "100%"}}
	    [:tr
	     [:th "Drunk"][:th "Event"][:th "Insult"][:th "Keyword"] [:td who]]
     (for [event @events]
       [:tr {:key (:id event)}
        [:td (or (and (:drunk event) "Hell Yeah!") "Nope")]
        [:td (:target event)]
        [:td (:content event)]
        [:td (:keyword event)]
        [:td [:a {:href "#/delete"} "Delete"]]])]]))

(.on fb "child_added" handle-childsnapshot)

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

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

{'fraction_non_alphanumeric': 0.16845441248171625, 'fraction_numerical': 0.0019502681618722574, 'mean_word_length': 2.2719298245614037, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, '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': '7218428', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1306, 'n_words': 393}