Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMR-10023: Part 1 #2151

Merged
merged 7 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion search-app/dev/user.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

(def system nil)


(defn create-system
[]
;; Set the default job start delay to avoid jobs kicking off with tests etc.
Expand Down
7 changes: 3 additions & 4 deletions search-app/src/cmr/search/api/association.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
(:require
[cheshire.core :as json]
[cmr.common-app.api.enabled :as common-enabled]
[cmr.common.log :refer (info)]
[cmr.common.log :refer (debug info)]
[cmr.common.mime-types :as mt]
[cmr.common.util :as util]
[cmr.search.services.association-service :as assoc-service]
[cmr.search.services.association-validation :as assoc-validation]
[compojure.core :refer :all]
[compojure.route :as route]))
[compojure.core :refer :all]))

(defn- validate-association-content-type
"Validates that content type sent with a association is JSON."
Expand Down Expand Up @@ -65,7 +64,7 @@
[context headers body concept-type concept-id]
(common-enabled/validate-write-enabled context "search")
(validate-association-content-type headers)
(info (format "Dissociating %s [%s] from collections: %s by client: %s."
(debug (format "Dissociating %s [%s] from collections: %s by client: %s."
(name concept-type) concept-id body (:client-id context)))
(if (and (> (count (map :concept-id (json/parse-string body true))) 1)
(= :variable concept-type))
Expand Down
4 changes: 1 addition & 3 deletions search-app/src/cmr/search/api/community_usage_metrics.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
[cmr.acl.core :as acl]
[cmr.common-app.api.routes :as cr]
[cmr.common.mime-types :as mt]
[cmr.common.services.errors :as errors]
[cmr.search.services.community-usage-metrics.metrics-service :as metrics-service]
[compojure.core :refer :all]
[compojure.route :as route]))
[compojure.core :refer :all]))

(defn- community-usage-metrics-response
"Creates a successful community usage metrics response with the given data response"
Expand Down
6 changes: 3 additions & 3 deletions search-app/src/cmr/search/api/concepts_lookup.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
(:require
[cmr.common-app.api.routes :as common-routes]
[cmr.common.concepts :as concepts]
[cmr.common.log :refer (debug info warn error)]
[cmr.common.log :refer (debug)]
[cmr.common.mime-types :as mt]
[cmr.common.services.errors :as svc-errors]
[cmr.search.api.core :as core-api]
Expand Down Expand Up @@ -73,13 +73,13 @@
(defn- find-concept-by-concept-id*
"Perfrom the retrieval of concept by concept id and revision id"
([ctx result-format concept-id]
(info (format "Search for concept with cmr-concept-id [%s]" concept-id))
(debug (format "Search for concept with cmr-concept-id [%s]" concept-id))
jmaeng72 marked this conversation as resolved.
Show resolved Hide resolved
(core-api/search-response
ctx
(query-svc/find-concept-by-id ctx result-format concept-id)))

([ctx result-format concept-id revision-id]
(info (format "Search for concept with cmr-concept-id [%s] and revision-id [%s]"
(debug (format "Search for concept with cmr-concept-id [%s] and revision-id [%s]"
concept-id
revision-id))
(core-api/search-response
Expand Down
16 changes: 7 additions & 9 deletions search-app/src/cmr/search/api/concepts_search.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
(:require
[cheshire.core :as json]
[clojure.string :as string]
[clojure.walk :as walk]
[cmr.common-app.api.launchpad-token-validation :refer [get-token-type]]
[cmr.common-app.api.routes :as common-routes]
[cmr.common-app.config :as common-app-config]
[cmr.common-app.services.search :as search]
[cmr.common.cache :as cache]
[cmr.common.config :as cfg :refer [defconfig]]
[cmr.common.config :refer [defconfig]]
[cmr.common.generics :as common-generic]
[cmr.common.log :refer (debug info warn error)]
[cmr.common.mime-types :as mt]
Expand All @@ -20,8 +19,7 @@
[cmr.search.services.query-service :as query-svc]
[cmr.search.services.result-format-helper :as rfh]
[cmr.search.validators.all-granule-validation :as all-gran-validation]
[compojure.core :refer :all]
[inflections.core :as inf]))
[compojure.core :refer :all]))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Constants and Utility Functions
Expand Down Expand Up @@ -287,7 +285,7 @@
"Retrieves a timeline of granules within each collection found."
[ctx path-w-extension params headers query-string]
(let [params (core-api/process-params :granule params path-w-extension headers mt/json)
_ (info (format "Getting granule timeline from client %s, token_type %s with params %s."
_ (debug (format "Getting granule timeline from client %s, token_type %s with params %s."
(:client-id ctx) (get-token-type (:token ctx)) (pr-str params)))
search-params (lp/process-legacy-psa params)]
(core-api/search-response ctx (query-svc/get-granule-timeline ctx search-params))))
Expand All @@ -299,7 +297,7 @@
_ (when (= :stac (:result-format params))
(svc-errors/throw-service-error
:bad-request "search by JSON query is not allowed with STAC result format"))
_ (info (format "Searching for concepts from client %s in format %s with AQL: %s and query parameters %s."
_ (debug (format "Searching for concepts from client %s in format %s with AQL: %s and query parameters %s."
(:client-id ctx) (rfh/printable-result-format (:result-format params)) aql params))
results (query-svc/find-concepts-by-aql ctx params aql)]
(core-api/search-response ctx results)))
Expand All @@ -320,7 +318,7 @@
"Invokes query service to search for collections that are deleted and returns the response"
[ctx path-w-extension params headers]
(let [params (core-api/process-params :collection params path-w-extension headers mt/xml)]
(info (format "Searching for deleted collections from client %s in format %s with params %s."
(debug (format "Searching for deleted collections from client %s in format %s with params %s."
(:client-id ctx) (rfh/printable-result-format (:result-format params))
(pr-str params)))
(core-api/search-response ctx (query-svc/get-deleted-collections ctx params))))
Expand All @@ -329,7 +327,7 @@
"Invokes query service to search for granules that are deleted and returns the response"
[ctx path-w-extension params headers]
(let [params (core-api/process-params nil params path-w-extension headers mt/xml)]
(info (format "Searching for deleted granules from client %s in format %s with params %s."
(debug (format "Searching for deleted granules from client %s in format %s with params %s."
(:client-id ctx) (rfh/printable-result-format (:result-format params))
(pr-str params)))
(core-api/search-response ctx (query-svc/get-deleted-granules ctx params))))
Expand Down Expand Up @@ -361,7 +359,7 @@
(json/parse-string true)
:scroll_id)]
(do
(info (format "Clear scroll: %s" short-scroll-id))
(debug (format "Clear scroll: %s" short-scroll-id))
;; if the short scroll id is valid, retrieve the real scroll id
(if-let [scroll-id (->> short-scroll-id
(core-api/get-scroll-id-and-search-params-from-cache context)
Expand Down
6 changes: 3 additions & 3 deletions search-app/src/cmr/search/api/generic_association.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[cheshire.core :as json]
[cmr.common-app.api.enabled :as common-enabled]
[cmr.common.concepts :as common-concepts]
[cmr.common.log :refer (info)]
[cmr.common.log :refer (debug)]
[cmr.common.mime-types :as mt]
[cmr.common.util :as util]
[cmr.search.services.generic-association-service :as generic-assoc-service]
Expand Down Expand Up @@ -43,7 +43,7 @@
[context headers body concept-id revision-id]
(common-enabled/validate-write-enabled context "search")
(validate-association-content-type headers)
(info (format "Associate concept [%s] revision [%s] on concepts: %s by client: %s."
(debug (format "Associate concept [%s] revision [%s] on concepts: %s by client: %s."
concept-id revision-id body (:client-id context)))
(let [concept-type (common-concepts/concept-id->type concept-id)
results (generic-assoc-service/associate-to-concepts context concept-type concept-id revision-id body)
Expand All @@ -56,7 +56,7 @@
[context headers body concept-id revision-id]
(common-enabled/validate-write-enabled context "search")
(validate-association-content-type headers)
(info (format "Dissociating concept [%s] revision [%s] from concepts: %s by client: %s."
(debug (format "Dissociating concept [%s] revision [%s] from concepts: %s by client: %s."
concept-id revision-id body (:client-id context)))
(let [concept-type (common-concepts/concept-id->type concept-id)
results (generic-assoc-service/dissociate-from-concepts context concept-type concept-id revision-id body)
Expand Down
4 changes: 2 additions & 2 deletions search-app/src/cmr/search/api/providers.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
(:require
[cheshire.core :as json]
[cmr.common-app.api.routes :as common-routes]
[cmr.common.log :refer (debug info warn error)]
[cmr.common.log :refer (debug)]
[cmr.common.mime-types :as mt]
[cmr.search.api.core :as core-api]
[cmr.search.services.provider-service :as provider-service]
Expand Down Expand Up @@ -31,7 +31,7 @@
"Invokes query service to retrieve provider holdings and returns the response"
[ctx path-w-extension params headers]
(let [params (core-api/process-params nil params path-w-extension headers mt/json)
_ (info (format "Searching for provider holdings from client %s in format %s with params %s."
_ (debug (format "Searching for provider holdings from client %s in format %s with params %s."
(:client-id ctx) (rfh/printable-result-format (:result-format params))
(pr-str params)))
[provider-holdings provider-holdings-formatted]
Expand Down
3 changes: 1 addition & 2 deletions search-app/src/cmr/search/api/services.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"Defines the API for associating/dissociating services with collections in the CMR."
(:require
[cmr.search.api.association :as association]
[compojure.core :refer :all]
[compojure.route :as route]))
[compojure.core :refer :all]))

(def service-api-routes
(context "/services" []
Expand Down
14 changes: 6 additions & 8 deletions search-app/src/cmr/search/api/tags.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
[clojure.string :as string]
[cmr.acl.core :as acl]
[cmr.common-app.api.enabled :as common-enabled]
[cmr.common-app.api.launchpad-token-validation :as lt-validation]
[cmr.common.log :refer (debug info warn error)]
[cmr.common.log :refer (debug)]
[cmr.common.mime-types :as mt]
[cmr.common.services.errors :as errors]
[cmr.common.util :as util]
[cmr.search.services.tagging-service :as tagging-service]
[cmr.transmit.config :as transmit-config]
[compojure.core :refer :all]
[compojure.route :as route]))
[compojure.core :refer :all]))

(defn- validate-tag-content-type
"Validates that content type sent with a tag is JSON"
Expand Down Expand Up @@ -81,7 +79,7 @@
(verify-tag-modification-permission context :update)
(common-enabled/validate-write-enabled context "search")
(validate-tag-content-type headers)
(info (format "Tagging [%s] on collections: %s by client: %s."
(debug (format "Tagging [%s] on collections: %s by client: %s."
tag-key body (:client-id context)))
(tag-api-response (tagging-service/associate-tag-to-collections context tag-key body)))

Expand All @@ -91,7 +89,7 @@
(verify-tag-modification-permission context :update)
(common-enabled/validate-write-enabled context "search")
(validate-tag-content-type headers)
(info (format "Dissociating tag [%s] from collections: %s by client: %s."
(debug (format "Dissociating tag [%s] from collections: %s by client: %s."
tag-key body (:client-id context)))
(tag-api-response (tagging-service/dissociate-tag-to-collections context tag-key body)))

Expand All @@ -101,7 +99,7 @@
(verify-tag-modification-permission context :update)
(common-enabled/validate-write-enabled context "search")
(validate-tag-content-type headers)
(info (format "Tagging [%s] on collections by query: %s by client: %s."
(debug (format "Tagging [%s] on collections by query: %s by client: %s."
jceaser marked this conversation as resolved.
Show resolved Hide resolved
tag-key body (:client-id context)))
(tag-api-response (tagging-service/associate-tag-by-query context tag-key body)))

Expand All @@ -111,7 +109,7 @@
(verify-tag-modification-permission context :update)
(common-enabled/validate-write-enabled context "search")
(validate-tag-content-type headers)
(info (format "Dissociating tag [%s] from collections by query: %s by client: %s."
(debug (format "Dissociating tag [%s] from collections by query: %s by client: %s."
tag-key body (:client-id context)))
(tag-api-response (tagging-service/dissociate-tag-by-query context tag-key body)))

Expand Down
3 changes: 1 addition & 2 deletions search-app/src/cmr/search/api/tools.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"Defines the API for associating/dissociating tools with collections in the CMR."
(:require
[cmr.search.api.association :as association]
[compojure.core :refer :all]
[compojure.route :as route]))
[compojure.core :refer :all]))

(def tool-api-routes
(context "/tools" []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
(:require
[cmr.elastic-utils.search.query-transform :as c2s]
[cmr.common.services.search.query-model :as cqm]
[cmr.search.models.query :as qm]
[cmr.search.services.query-execution.has-granules-results-feature :as has-granules-base]))

;; The following protocol implementation ensures that a c.s.m.q.HasGranulesCondition record in our
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
(:require
[cmr.elastic-utils.search.query-transform :as c2s]
[cmr.common.services.search.query-model :as cqm]
[cmr.search.models.query :as qm]
[cmr.search.services.query-execution.has-granules-or-cwic-results-feature :as has-gran-or-cwic-base]
[cmr.search.services.query-execution.has-granules-results-feature :as has-granules-base]))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
protocol for two d coordinate system related search fields."
(:require [cmr.common.services.search.query-model :as qm]
[cmr.elastic-utils.search.es-group-query-conditions :as gc]
[cmr.elastic-utils.search.query-transform :as c2s]
[cmr.common.services.errors :as errors]))
[cmr.elastic-utils.search.query-transform :as c2s]))

(defprotocol ConvertCoordinateCondition
(coordinate-cond->condition
Expand Down
2 changes: 1 addition & 1 deletion search-app/src/cmr/search/data/elastic_search_index.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
(:require
[clojure.string :as string]
[cmr.common.concepts :as concepts]
[cmr.common.config :as cfg :refer [defconfig]]
[cmr.common.config :refer [defconfig]]
[cmr.common.hash-cache :as hcache]
[cmr.common.services.errors :as e]
[cmr.common.services.search.query-model :as qm]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
[cmr.common.hash-cache :as hash-cache]
[cmr.common.memory-db.connection]
[cmr.common.jobs :refer [defjob]]
[cmr.common.log :as log :refer [debug info]]
[cmr.common.log :refer [debug info]]
[cmr.common.redis-log-util :as rl-util]
[cmr.common.services.errors :as errors]
[cmr.common.util :as u]
Expand Down Expand Up @@ -75,8 +75,8 @@
(defn refresh-cache
"Refreshes the collection metadata cache"
[context]
(info "Refreshing metadata cache")
(let [incremental-since-refresh-date (str (clj-time.core/now))
(let [start-time (System/currentTimeMillis)
incremental-since-refresh-date (str (clj-time.core/now))
concepts-tuples (cmn-coll-metadata-cache/fetch-collections-from-elastic context)
new-cache-value (reduce #(merge %1 (concept-tuples->cache-map context %2))
{}
Expand All @@ -91,15 +91,15 @@
cmn-coll-metadata-cache/collection-metadata-cache-fields-key
(vec (remove nil? (keys new-cache-value))))
(hash-cache/set-values rcache cmn-coll-metadata-cache/cache-key new-cache-value)
(info "Metadata cache refresh complete. Cache Size:"
(hash-cache/cache-size rcache cmn-coll-metadata-cache/cache-key))))
(info "Metadata cache refresh complete. Took %d ms. Cache Size:"
((System/currentTimeMillis) - start-time) (hash-cache/cache-size rcache cmn-coll-metadata-cache/cache-key))))

(defn update-cache-job
"Updates the collection metadata cache by querying elastic search for updates since the
last time the cache was updated."
[context]
(info "Updating collection metadata cache")
(let [cache (hash-cache/context->cache context cmn-coll-metadata-cache/cache-key)
(let [start-time (System/currentTimeMillis)
cache (hash-cache/context->cache context cmn-coll-metadata-cache/cache-key)
incremental-since-refresh-date (str (t/now))
concepts-tuples (cmn-coll-metadata-cache/fetch-updated-collections-from-elastic context)
new-cache-value (reduce #(merge %1 (concept-tuples->cache-map context %2))
Expand All @@ -121,7 +121,7 @@
(hash-cache/set-values cache
cmn-coll-metadata-cache/cache-key
new-cache-value)
(info "Metadata cache update complete. Cache Size:" (hash-cache/cache-size cache cmn-coll-metadata-cache/cache-key))))
(info "Metadata cache update complete. Took %d ms. Cache Size:" ((System/currentTimeMillis) - start-time) (hash-cache/cache-size cache cmn-coll-metadata-cache/cache-key))))

(defn in-memory-db?
"Checks to see if the database in the context is an in-memory db."
Expand Down
4 changes: 1 addition & 3 deletions search-app/src/cmr/search/data/query_order_by_expense.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"Sorts query conditions within a query by their execution expense. Elasticsearch recommend putting
cached filters before uncached filters. Expensive queries like exact spatial intersection should
be placed last."
(:require [cmr.common.services.errors :as errors]
[cmr.search.models.query :as qm]
[cmr.elastic-utils.search.es-query-order-by-expense :as qobe])
(:require [cmr.elastic-utils.search.es-query-order-by-expense :as qobe])
(:import [cmr.search.models.query
CollectionQueryCondition
SpatialCondition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"This test tests the pure functions get-validate-keyword-wildcards-msg"
(:require
[clojure.test :refer :all]
[cmr.common.util :as u :refer [are3]]
[cmr.common.util :refer [are3]]
[cmr.search.data.query-to-elastic :as query-to-elastic]))

(deftest get-validate-keyword-wildcards-msg-test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"This tests the opendata-results-handler namespace."
(:require
[clojure.test :refer :all]
[cmr.common.util :as util :refer [are3]]
[cmr.common.util :refer [are3]]
[cmr.search.results-handlers.opendata-results-handler :as opendata-results-handler]))

(deftest distribution-is-downloadable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns cmr.search.test.unit.results-handlers.results-handler-util
(:require [clojure.test :refer :all]
[cmr.common.util :as util :refer [are3]]
[cmr.common.util :refer [are3]]
[cmr.search.results-handlers.results-handler-util :as rs-util]))

(deftest convert-associations-test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
(:require
[clojure.test :refer :all]
[cmr.common.util :as util :refer [are3]]
[cmr.search.results-handlers.stac-results-handler :as stac-results-handler]
[ring.util.codec :as codec]))
[cmr.search.results-handlers.stac-results-handler :as stac-results-handler]))

(def ^:private metadata-link
"example metadata-link for test"
Expand Down
Loading