<commit_before>(ns fcms.resources.collection-resource
  (:require [clojure.set :refer (intersection)]
            [clojure.string :refer (blank?)]
            [clojure.walk :refer (keywordize-keys)]
            [com.ashafa.clutch :as clutch]
            [fcms.resources.common :as common]
            [fcms.resources.collection :as collection]
            [fcms.lib.slugify :refer (slugify)]))

;; A collection resource is an FCMS resource that is contained in a particular collection.
;; As of now, collection resources are either taxonomies or items.

(def reserved-properties
  "Properties that can't be specified during a create and are ignored during an update."
  (conj common/reserved-properties :collection :categories))
(def retained-properties
  "Properties that are retained during an update even if they aren't in the updated property set."
  (conj common/retained-properties :collection :categories))

(defn allow-category-reserved-properties []
  (vec (remove #(= :categories %) reserved-properties)))

(defn- get-resource-with-db [coll-id coll-slug slug type]
  (when-let [resource (common/resource-doc coll-id slug type)]
    (common/resource-from-db coll-slug resource)))

(defn get-resource
  "Given the slug of the collection containing the resource and the slug of the resource,<commit_msg>Moved ns comment to docstring.<commit_after>(ns fcms.resources.collection-resource
  "A collection resource is an FCMS resource that is contained in one particular collection.
  Collection resources are either taxonomies or items."
  (:require [clojure.set :refer (intersection)]
            [clojure.string :refer (blank?)]
            [clojure.walk :refer (keywordize-keys)]
            [com.ashafa.clutch :as clutch]
            [fcms.resources.common :as common]
            [fcms.resources.collection :as collection]
            [fcms.lib.slugify :refer (slugify)]))

(def reserved-properties
  "Properties that can't be specified during a create and are ignored during an update."
  (conj common/reserved-properties :collection :categories))
(def retained-properties
  "Properties that are retained during an update even if they aren't in the updated property set."
  (conj common/retained-properties :collection :categories))

(defn allow-category-reserved-properties []
  (vec (remove #(= :categories %) reserved-properties)))

(defn- get-resource-with-db [coll-id coll-slug slug type]
  (when-let [resource (common/resource-doc coll-id slug type)]
    (common/resource-from-db coll-slug resource)))

(defn get-resource
  "Given the slug of the collection containing the resource and the slug of the resource,
{'fraction_non_alphanumeric': 0.10125618576322802, 'fraction_numerical': 0.0, 'mean_word_length': 3.7781818181818183, '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': '2755127', 'n_tokens_mistral': 735, 'n_tokens_neox': 724, 'n_words': 256}