<commit_before>(ns oc.storage.api.videos
  "Liberator API for ziggeo video resources."
  (:require [taoensso.timbre :as timbre]
            [compojure.core :as compojure :refer (POST)]
            [liberator.core :refer (defresource by-method)]
            [oc.lib.db.pool :as pool]
            [oc.lib.api.common :as api-common]
            [oc.storage.async.notification :as notification]
            [oc.storage.resources.entry :as entry-res]
            [oc.storage.resources.org :as org-res]
            [oc.storage.resources.board :as board-res]
            [oc.storage.config :as config]))

(defn- handle-video-webhook [conn ctx]
  (let [body (:data ctx)
        video (get-in body [:data :video])
        token (:token video)
        entry (if token
                (entry-res/get-entry-by-video conn token)
                false)
        video-changed (:video-processed entry)]
    (timbre/debug (:state_string video) video entry)
    (when entry
      (let [error (contains? ["EMPTY" "ERROR"] (:state_string video))
            updated-result (if-not error
                             (entry-res/update-video-data conn video entry)
                             (entry-res/error-video-data conn entry))
            ;; find org
            org (org-res/get-org conn (:org-uuid entry))
            ;; find board
            board (board-res/get-board conn (:board-uuid entry))]
        (when (not= (:video-processed updated-result) video-changed)<commit_msg>use some instead of contains?<commit_after>(ns oc.storage.api.videos
  "Liberator API for ziggeo video resources."
  (:require [taoensso.timbre :as timbre]
            [compojure.core :as compojure :refer (POST)]
            [liberator.core :refer (defresource by-method)]
            [oc.lib.db.pool :as pool]
            [oc.lib.api.common :as api-common]
            [oc.storage.async.notification :as notification]
            [oc.storage.resources.entry :as entry-res]
            [oc.storage.resources.org :as org-res]
            [oc.storage.resources.board :as board-res]
            [oc.storage.config :as config]))

(defn- handle-video-webhook [conn ctx]
  (let [body (:data ctx)
        video (get-in body [:data :video])
        token (:token video)
        entry (if token
                (entry-res/get-entry-by-video conn token)
                false)
        video-changed (:video-processed entry)]
    (timbre/debug (:state_string video) video entry)
    (when entry
      (let [error (some #(= (:state_string video) %) ["EMPTY", "ERROR"])
            updated-result (if-not error
                             (entry-res/update-video-data conn video entry)
                             (entry-res/error-video-data conn entry))
            ;; find org
            org (org-res/get-org conn (:org-uuid entry))
            ;; find board
            board (board-res/get-board conn (:board-uuid entry))]
        (when (not= (:video-processed updated-result) video-changed)
{'fraction_non_alphanumeric': 0.12605896306336836, 'fraction_numerical': 0.0, 'mean_word_length': 1.954954954954955, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '98487', 'n_tokens_mistral': 890, 'n_tokens_neox': 857, 'n_words': 225}