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 all commits
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
3 changes: 1 addition & 2 deletions search-app/src/cmr/search/api/association.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
[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
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
8 changes: 3 additions & 5 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 @@ -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
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
12 changes: 5 additions & 7 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.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 @@ -76,7 +76,8 @@
"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 +92,16 @@
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 +123,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
4 changes: 2 additions & 2 deletions search-app/src/cmr/search/middleware/shapefile.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"Contains parameter converters for shapefile parameter"
(:require
[ring.middleware.multipart-params :refer [wrap-multipart-params]]
[cmr.common.config :as cfg :refer [defconfig]]
[cmr.common.config :refer [defconfig]]
[cmr.common.api.errors :as api-errors]
[cmr.common.log :refer [debug error]]
[cmr.common.log :refer [error]]
[cmr.common.services.errors :as errors])
(:import
(java.io BufferedInputStream File FileReader FileOutputStream FileInputStream)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
(ns cmr.search.middleware.shapefile-simplification
"Middleware to optionally reduce the complexity of shapefiles"
(:require
[clojure.java.io :as io]
[cheshire.core :as json]
[cmr.common.config :as cfg :refer [defconfig]]
[cmr.common.config :refer [defconfig]]
[cmr.common.api.errors :as api-errors]
[cmr.common.log :refer [debug]]
[cmr.common.mime-types :as mt]
[cmr.common.services.errors :as errors]
[cmr.search.services.parameters.converters.geojson :as geojson]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
(ns cmr.search.results-handlers.stac-spatial-results-handler
"A helper for converting spatial shapes into stac results"
(:require
[cmr.spatial.cartesian-ring :as cr]
[cmr.spatial.derived :as d]
[cmr.spatial.geodetic-ring :as gr]
[cmr.spatial.line-string :as l]
[cmr.spatial.mbr :as m]
[cmr.spatial.point :as p]
[cmr.spatial.polygon :as poly]))
[cmr.spatial.mbr :as m]))

(defprotocol stacSpatialHandler
"Converts a spatial shape into GeoJSON structures"
Expand Down
1 change: 0 additions & 1 deletion search-app/src/cmr/search/validators/opendata.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(ns cmr.search.validators.opendata
"Validate Opendata formatted collections against JSON schema in /resources/schema"
(:require
[clojure.java.io :as io]
[cmr.common.validations.json-schema :as json-schema]))

(defn- load-opendata-schema
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
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
(ns cmr.search.test.unit.results-handlers.stac-spatial-results-handler
(:require
[clojure.test :refer :all]
[cmr.common.util :as util :refer [are3]]
[cmr.common.util :refer [are3]]
[cmr.search.results-handlers.stac-spatial-results-handler :as ssrh]
[cmr.spatial.cartesian-ring :as cr]
[cmr.spatial.derived :as d]
[cmr.spatial.geodetic-ring :as gr]
[cmr.spatial.ring-relations :as rr]
[cmr.spatial.line-string :as l]
[cmr.spatial.mbr :as m]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
(ns cmr.search.test.unit.results-handlers.timeline-results-handler
(:require [clojure.test :refer :all]
[cmr.common.test.test-check-ext :refer [defspec]]
[clojure.test.check.properties :refer [for-all]]
[clojure.test.check.generators :as gen]
[cmr.search.results-handlers.timeline-results-handler :as trh]
[clj-time.core :as t]
[clj-time.coerce :as c]))
[clj-time.core :as t]))

(deftest adjacent-interval-test
(testing "year"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[cmr.common.hash-cache :as hash-cache]
[cmr.redis-utils.config :as redis-config]
[cmr.redis-utils.redis-hash-cache :as redis-hash-cache]
[cmr.common.util :as util :refer [are3]]
[cmr.common.util :refer [are3]]
[cmr.redis-utils.test.test-util :as test-util]
[cmr.search.services.acls.granule-acls :as g]))

Expand Down