<commit_before>(ns ^{:doc "helper to provide the urls to various service endpoints"}
  cmr.system-int-test.utils.url-helper
  (:require [ring.util.codec :as codec]
            [clojure.string :as str]))

(defn config-value
  "Retrieves a configuration value which can be set as an environment variable on the command line
  or default to a value"
  [config-name default-value]
  (let [env-name (str "CMR_" (-> config-name
                                 name
                                 (str/replace "-" "_")
                                 str/upper-case))]
    (or (System/getenv env-name)
        default-value)))

(def elastic-port (config-value :elastic-port 9210))

(def metadata-db-port (config-value :metadata-db-port 3001))

(def ingest-port (config-value :ingest-port 3002))

(def indexer-port (config-value :indexer-port 3004))

(def search-port (config-value :search-port 3000))

(def elastic_root (format "http://localhost:%s" elastic-port))

(def create-provider-url (format "http://localhost:%s/providers" metadata-db-port))

(defn delete-provider-url
  [provider-id]
  (format "http://localhost:%s/providers/%s" metadata-db-port provider-id))

(defn collection-ingest-url
  [provider-id native-id]
  (format "http://localhost:%s/providers/%s/collections/%s"
          ingest-port
          provider-id
          native-id))

(defn collection-search-url
  [params]
  (format "http://localhost:%s/collections?%s" search-port (codec/form-encode params)))

(defn granule-ingest-url
  [provider-id native-id]
  (format "http://localhost:%s/providers/%s/granules/%s"
          ingest-port
          provider-id
          native-id))

(defn granule-search-url
  [params]
  (format "http://localhost:%s/granules?%s" search-port (codec/form-encode params)))

(defn elastic-flush-url
  []
  (str elastic_root "/_flush"))

(defn mdb-concept-url
  "URL to concept in mdb."
  [concept-id revision-id]
  (format "http://localhost:%s/concepts/%s/%s" metadata-db-port concept-id revision-id))

(defn mdb-reset-url
  "Force delete all concepts from mdb."
  []
  (format "http://localhost:%s/reset" metadata-db-port))

(defn indexer-reset-url
  "Delete and re-create indexes in elastic. Only development team to use this functionality."
  []
  (format "http://localhost:%s/reset" indexer-port))

;; discard this once oracle impl is in place
(defn mdb-concept-coll-id-url
  "URL to access a collection concept in mdb with given prov and native id."
  [provider-id native-id]
  (format "http://localhost:%s/concept-id/collection/%s/%s"
          metadata-db-port
          provider-id
          native-id))


<commit_msg>CMR-192: Fixed search port.<commit_after>(ns ^{:doc "helper to provide the urls to various service endpoints"}
  cmr.system-int-test.utils.url-helper
  (:require [ring.util.codec :as codec]
            [clojure.string :as str]))

(defn config-value
  "Retrieves a configuration value which can be set as an environment variable on the command line
  or default to a value"
  [config-name default-value]
  (let [env-name (str "CMR_" (-> config-name
                                 name
                                 (str/replace "-" "_")
                                 str/upper-case))]
    (or (System/getenv env-name)
        default-value)))

(def elastic-port (config-value :elastic-port 9210))

(def metadata-db-port (config-value :metadata-db-port 3001))

(def ingest-port (config-value :ingest-port 3002))

(def indexer-port (config-value :indexer-port 3004))

(def search-port (config-value :search-port 3003))

(def elastic_root (format "http://localhost:%s" elastic-port))

(def create-provider-url (format "http://localhost:%s/providers" metadata-db-port))

(defn delete-provider-url
  [provider-id]
  (format "http://localhost:%s/providers/%s" metadata-db-port provider-id))

(defn collection-ingest-url
  [provider-id native-id]
  (format "http://localhost:%s/providers/%s/collections/%s"
          ingest-port
          provider-id
          native-id))

(defn collection-search-url
  [params]
  (format "http://localhost:%s/collections?%s" search-port (codec/form-encode params)))

(defn granule-ingest-url
  [provider-id native-id]
  (format "http://localhost:%s/providers/%s/granules/%s"
          ingest-port
          provider-id
          native-id))

(defn granule-search-url
  [params]
  (format "http://localhost:%s/granules?%s" search-port (codec/form-encode params)))

(defn elastic-flush-url
  []
  (str elastic_root "/_flush"))

(defn mdb-concept-url
  "URL to concept in mdb."
  [concept-id revision-id]
  (format "http://localhost:%s/concepts/%s/%s" metadata-db-port concept-id revision-id))

(defn mdb-reset-url
  "Force delete all concepts from mdb."
  []
  (format "http://localhost:%s/reset" metadata-db-port))

(defn indexer-reset-url
  "Delete and re-create indexes in elastic. Only development team to use this functionality."
  []
  (format "http://localhost:%s/reset" indexer-port))

;; discard this once oracle impl is in place
(defn mdb-concept-coll-id-url
  "URL to access a collection concept in mdb with given prov and native id."
  [provider-id native-id]
  (format "http://localhost:%s/concept-id/collection/%s/%s"
          metadata-db-port
          provider-id
          native-id))



{'fraction_non_alphanumeric': 0.14386164956290384, 'fraction_numerical': 0.008171797795515013, 'mean_word_length': 2.94527736131934, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7549384', 'n_tokens_mistral': 1775, 'n_tokens_neox': 1695, 'n_words': 425}