<commit_before>(ns cmr.search.results-handlers.umm-json-results-handler
  "Handles the umm-json results format and related functions"
  (:require [cmr.common-app.services.search.elastic-results-to-query-results :as elastic-results]
            [cmr.common-app.services.search.elastic-search-index :as elastic-search-index]
            [cmr.common-app.services.search :as qs]
            [cheshire.core :as json]
            [clojure.string :as str]
            [cmr.common.util :as util]
            [cmr.common.mime-types :as mt]))

(defmethod elastic-search-index/concept-type+result-format->fields [:collection :umm-json]
  [concept-type query]
  ["concept-id"
   "native-id"
   "user-id"
   "provider-id"
   "entry-title"
   "entry-id"
   "short-name"
   "version-id"
   "revision-date2"
   "deleted"
   "metadata-format"])

(defmethod elastic-results/elastic-result->query-result-item [:collection :umm-json]
  [context query elastic-result]
  (let [{[concept-id] :concept-id
         [native-id] :native-id
         [user-id] :user-id
         [provider-id] :provider-id
         [entry-title] :entry-title
         [entry-id] :entry-id
         [short-name] :short-name
         [version-id] :version-id
         [revision-date] :revision-date2
         [deleted] :deleted
         [metadata-format] :metadata-format} (:fields elastic-result)
        revision-date (when revision-date (str/replace (str revision-date) #"\+0000" "Z"))
        revision-id (:_version elastic-result)]
    {:meta (util/remove-nil-keys
             {:concept-type :collection
              :concept-id concept-id
              :revision-id revision-id
              :native-id native-id
              :user-id user-id
              :provider-id provider-id
              :format (mt/format->mime-type (keyword metadata-format))
              :revision-date revision-date
              :deleted deleted})
     :umm {:entry-title entry-title<commit_msg>Making quick fix to add revision date back to umm json results.<commit_after>(ns cmr.search.results-handlers.umm-json-results-handler
  "Handles the umm-json results format and related functions"
  (:require [cmr.common-app.services.search.elastic-results-to-query-results :as elastic-results]
            [cmr.common-app.services.search.elastic-search-index :as elastic-search-index]
            [cmr.common-app.services.search :as qs]
            [cheshire.core :as json]
            [clojure.string :as str]
            [cmr.common.util :as util]
            [cmr.common.mime-types :as mt]))

(defmethod elastic-search-index/concept-type+result-format->fields [:collection :umm-json]
  [concept-type query]
  ["concept-id"
   "native-id"
   "user-id"
   "provider-id"
   "entry-title"
   "entry-id"
   "short-name"
   "version-id"
   "revision-date"
   "deleted"
   "metadata-format"])

(defmethod elastic-results/elastic-result->query-result-item [:collection :umm-json]
  [context query elastic-result]
  (let [{[concept-id] :concept-id
         [native-id] :native-id
         [user-id] :user-id
         [provider-id] :provider-id
         [entry-title] :entry-title
         [entry-id] :entry-id
         [short-name] :short-name
         [version-id] :version-id
         [revision-date] :revision-date
         [deleted] :deleted
         [metadata-format] :metadata-format} (:fields elastic-result)
        revision-date (when revision-date (str/replace (str revision-date) #"\+0000" "Z"))
        revision-id (:_version elastic-result)]
    {:meta (util/remove-nil-keys
             {:concept-type :collection
              :concept-id concept-id
              :revision-id revision-id
              :native-id native-id
              :user-id user-id
              :provider-id provider-id
              :format (mt/format->mime-type (keyword metadata-format))
              :revision-date revision-date
              :deleted deleted})
     :umm {:entry-title entry-title
{'fraction_non_alphanumeric': 0.13640999490056094, 'fraction_numerical': 0.0025497195308516064, 'mean_word_length': 2.310548523206751, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '2894189', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1220, 'n_words': 244}