<commit_before>;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) 2016 <NAME> <<EMAIL>>

(ns uxbox.emails
  (:require [suricatta.core :as sc]
            [uxbox.persistence :as up]
            [uxbox.config :as cfg]
            [uxbox.sql :as sql]
            [uxbox.util.blob :as blob]
            [uxbox.util.transit :as t]
            [uxbox.util.emails :as emails]))

(def register-email
  #(emails/render "register" % {:reply-to "<EMAIL>"}))

(defn send!
  ([email] (send! sender email 5))
  ([email priority]
   (let [defaults (:email cfg/config)
         email (merge defaults email)
         data (-> email t/encode blob/encode)
         sqlv (sql/insert-email {:data data
                                 :priority priority})]
     (with-open [conn (up/get-conn)]
       (sc/atomic conn
         (sc/execute conn sqlv))))))<commit_msg>Minor fix on email ns.<commit_after>;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) 2016 <NAME> <<EMAIL>>

(ns uxbox.emails
  (:require [suricatta.core :as sc]
            [uxbox.persistence :as up]
            [uxbox.config :as cfg]
            [uxbox.sql :as sql]
            [uxbox.util.blob :as blob]
            [uxbox.util.transit :as t]
            [uxbox.util.emails :as emails]))

(def register-email
  #(emails/render "register" % {:reply-to "<EMAIL>@uxbox.io"}))

(defn send!
  ([email] (send! email 5))
  ([email priority]
   (let [defaults (:email cfg/config)
         email (merge defaults email)
         data (-> email t/encode blob/encode)
         sqlv (sql/insert-email {:data data
                                 :priority priority})]
     (with-open [conn (up/get-conn)]
       (sc/atomic conn
         (sc/execute conn sqlv))))))
{'fraction_non_alphanumeric': 0.14159725624693778, 'fraction_numerical': 0.008819206271435572, 'mean_word_length': 2.231012658227848, 'pattern_counts': {'":': 0, '<': 11, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3058951', 'n_tokens_mistral': 678, 'n_tokens_neox': 651, 'n_words': 212}