Skip to content

Commit 98e6645

Browse files
authored
Merge pull request #983 from MITLibraries/timx-677
Stop logging GraphQL query and adds searchterm log
2 parents 7d2c34b + 4ab3906 commit 98e6645

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

app/graphql/types/query_type.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ def record_id(id:, index:)
115115
def search(searchterm:, citation:, contributors:, funding_information:, geodistance:, geobox:, identifiers:,
116116
locations:, subjects:, title:, index:, source:, from:, boolean_type:, fulltext:, per_page: 20,
117117
query_mode: 'keyword', use_global_scoring: false, tuning_parameters_input: nil, **filters)
118+
Rails.logger.info("Searchterm: #{format_searchterm_for_log(searchterm)}")
119+
118120
query = construct_query(searchterm, citation, contributors, funding_information, geodistance, geobox, identifiers,
119121
locations, subjects, title, source, boolean_type, filters, per_page, query_mode)
120122

@@ -204,6 +206,12 @@ def source_deprecation_handler(query, new_source, old_source)
204206
query
205207
end
206208

209+
def format_searchterm_for_log(searchterm)
210+
return '[missing]' if searchterm.blank?
211+
212+
searchterm.to_s.truncate(200)
213+
end
214+
207215
def validate_and_build_semantic_options(tuning_parameters)
208216
return {} if tuning_parameters.blank?
209217

config/initializers/filter_parameter_logging.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
# Use this to limit dissemination of sensitive information.
55
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
66
Rails.application.config.filter_parameters += [
7-
:passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :cvv, :cvc
7+
:passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :cvv, :cvc, :query
88
]

0 commit comments

Comments
 (0)