<commit_before>(ns issues.core
  (:require [cheshire.core :as json]
            [clj-jgit.porcelain :as git]))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Data model

(defrecord Card
  [id
   idList
   idBoard
   name
   desc
   closed])

(defrecord Board
  [id])

(defrecord List
  [id
   name
   idBoard])

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Read API

(defn get-lists [boardId]
  )

(defn get-cards [boardId]
  )

(defn get-card [cardId]
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Write API

(defn add-card [card]
  )

(defn update-card [old-card new-card]
  ;; this should be a generic method, to differentiate based upon change: move, comment, ...
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Git interfacing

(defn repo []
  (git/load-repo "testdata/"))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Ability to read/write files


;; this does read the first card from trello, populating all fields given in json.
(defn read-cards []
  (mapv map->Card
        (json/parse-stream
          (clojure.java.io/reader "./testdata/cards.json")
          true
          )))

;; this writes all the cards to foo.json
(defn write-cards [cards]
  (json/generate-stream
    cards
    (clojure.java.io/writer "./testdata/foo.json")<commit_msg>cleaned up data and code structure<commit_after>(ns issues.core
  (:require [cheshire.core :as json]
            [clj-jgit.porcelain :as git]))


(def dataRepo "dataRepo/")
(def board "board.json")
(def cards "cards.json")
(def lists "lists.json")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Data model

(defrecord Card
  [id
   idList
   idBoard
   name
   desc
   closed])

(defrecord Board
  [id])

(defrecord List
  [id
   name
   idBoard])

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Read API

(defn get-board []
  )

(defn get-lists [boardId]
  )

(defn get-cards [boardId]
  )

(defn get-card [cardId]
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Write API

(defn add-card [card]
  )

(defn update-card [old-card new-card]
  ;; this should be a generic method, to differentiate based upon change: move, comment, ...
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Git interfacing

(defn repo []
  (git/load-repo dataRepo))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Ability to read/write files

(defn read-from-json [what]
  (json/parse-stream
    (clojure.java.io/reader (str "./" dataRepo what))
    true))

(defn read-board []
  (map->Board
    (read-from-json board)))

(defn read-multiple [convert-fn what]
  (mapv convert-fn
        (read-from-json what)))

(defn read-cards []
  (read-multiple map->Card cards))

(defn read-lists []
  (read-multiple map->List lists))





;; this writes all the cards to foo.json
(defn write-cards [cards]
  (json/generate-stream
    cards
    (clojure.java.io/writer "./testdata/foo.json")
{'fraction_non_alphanumeric': 0.2752454417952314, 'fraction_numerical': 0.0, 'mean_word_length': 3.5142405063291138, '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': '4518393', 'n_tokens_mistral': 1126, 'n_tokens_neox': 1003, 'n_words': 240}