<commit_before>(ns braid.server.db.bot
  (:require
    [datomic.api :as d]
    [braid.server.crypto :as crypto :refer [random-nonce]]
    [braid.server.db :as db]
    [braid.server.db.common :refer [bot-pull-pattern db->bot]]
    [braid.server.db.user :as user]))

;; Queries

(defn bots-in-group
  [group-id]
  (->> (d/q '[:find [(pull ?b pull-pattern) ...]
              :in $ pull-pattern ?group-id
              :where
              [?g :group/id ?group-id]
              [?b :bot/group ?g]]
            (db/db) bot-pull-pattern group-id)
       (into #{} (map db->bot))))

(defn bot-by-name-in-group
  [name group-id]
  (some-> (d/q '[:find (pull ?b pull-pattern) .
                 :in $ pull-pattern ?group-id ?name
                 :where
                 [?g :group/id ?group-id]
                 [?b :bot/group ?g]<commit_msg>Fix requires order in bot.clj<commit_after>(ns braid.server.db.bot
  (:require
    [braid.server.crypto :as crypto :refer [random-nonce]]
    [braid.server.db :as db]
    [braid.server.db.common :refer [bot-pull-pattern db->bot]]
    [braid.server.db.user :as user]
    [datomic.api :as d]))

(defn bots-in-group
  [group-id]
  (->> (d/q '[:find [(pull ?b pull-pattern) ...]
              :in $ pull-pattern ?group-id
              :where
              [?g :group/id ?group-id]
              [?b :bot/group ?g]]
            (db/db) bot-pull-pattern group-id)
       (into #{} (map db->bot))))

(defn bot-by-name-in-group
  [name group-id]
  (some-> (d/q '[:find (pull ?b pull-pattern) .
                 :in $ pull-pattern ?group-id ?name
                 :where
                 [?g :group/id ?group-id]
                 [?b :bot/group ?g]
{'fraction_non_alphanumeric': 0.1807875894988067, 'fraction_numerical': 0.0, 'mean_word_length': 1.7810945273631842, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '4982566', 'n_tokens_mistral': 616, 'n_tokens_neox': 615, 'n_words': 136}