<commit_before>(ns otto.control
  (:require [clojure.core.async :as async :refer [<! alts!! chan close! go timeout]]
            [otto.github :as github]))

(defn- update-repository
  [repos v k]
  (println v k)
  (not (nil? v)))

(defn- update-repositories
  [orgs user update-fn]
  (let [r (chan)
        t (timeout 1000)]
    (doseq [o orgs]
      (github/fetch-repositories o user r))
    (loop []
      (if (update-fn (alts!! [r t]))
        (recur)
        (do (close! r)
            (close! t))))))

(defn periodically-update
  [orgs user interval repos]
  (let [update-fn #(apply update-repository repos %)]
    (go (loop []
          (<! (timeout interval))
          (update-repositories orgs user update-fn)
          (recur)))))<commit_msg>wip: control flow with results chan per org<commit_after>(ns otto.control
  (:require [clojure.core.async :as async :refer [<! alts!! chan close! go timeout]]
            [otto.github :as github]))

(defn- update-repository
  [repos r]
  (if (nil? r)
    false
    (do (println r)
        true)))

(defn- update-repositories
  [org user repo-fn]
  (let [r (chan)
        t (timeout 1000)]
    (github/fetch-repositories org user r)
    (loop []
      (if (apply repo-fn (alts!! [r t]))
        (recur)))))

(defn periodically-update
  [orgs user interval repos]
  (doseq [o orgs]
    (go (loop []
          (<! (timeout interval))
          (update-repositories o user (fn [r _]
                                        (update-repository repos r)))
          (recur)))))
{'fraction_non_alphanumeric': 0.15177398160315375, 'fraction_numerical': 0.005256241787122208, 'mean_word_length': 2.2682403433476397, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4361534', 'n_tokens_mistral': 538, 'n_tokens_neox': 506, 'n_words': 154}