Skip to content

Commit

Permalink
Merge branch 'master' into feature_metric_from_rest
Browse files Browse the repository at this point in the history
  • Loading branch information
kjgarza authored Feb 2, 2020
2 parents f3bb62d + 8111a32 commit 88c2d5e
Show file tree
Hide file tree
Showing 82 changed files with 6,456 additions and 259 deletions.
4 changes: 4 additions & 0 deletions .hound.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ruby:
config_file: .rubocop.yml
rubocop:
version: 0.77.0
11 changes: 8 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,21 @@ gem "graphql-errors", "~> 0.4.0"
gem "graphql-batch", "~> 0.4.1"
gem "batch-loader", "~> 1.4", ">= 1.4.1"
gem "graphql-cache", "~> 0.6.0", git: "https://github.com/stackshareio/graphql-cache"
gem "apollo-federation", "~> 0.5.1"
gem 'apollo-federation', '~> 1.0'
gem "google-protobuf", "3.10.0.rc.1"
gem "sprockets", "~> 3.7", ">= 3.7.2"
gem 'uuid', '~> 2.3', '>= 2.3.9'
gem 'strong_migrations', '~> 0.6.0'
gem 'crawler_detect'
gem 'lhm', '~> 2.2'

group :development, :test do
gem "rspec-rails", "~> 3.8", ">= 3.8.2"
gem "rspec-benchmark", "~> 0.4.0"
gem 'rubocop', '~> 0.77.0'
gem "rspec-graphql_matchers", "~> 1.1"
gem "rubocop", "~> 0.77.0"
gem 'rubocop-performance', '~> 1.5', '>= 1.5.1'
gem 'rubocop-rails', '~> 2.4'
gem "rubocop-rails", "~> 2.4"
gem "better_errors"
gem "binding_of_caller"
gem "byebug", platforms: [:mri, :mingw, :x64_mingw]
Expand Down
76 changes: 46 additions & 30 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,21 @@ GEM
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
ansi (1.5.0)
apollo-federation (0.5.1)
google-protobuf
graphql
apollo-federation (1.0.1)
google-protobuf (~> 3.7)
graphql (~> 1.9.8)
arel (9.0.0)
ast (2.4.0)
audited (4.9.0)
activerecord (>= 4.2, < 6.1)
aws-eventstream (1.0.3)
aws-partitions (1.263.0)
aws-sdk-core (3.88.0)
aws-partitions (1.269.0)
aws-sdk-core (3.89.1)
aws-eventstream (~> 1.0, >= 1.0.2)
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-kms (1.27.0)
aws-sdk-kms (1.28.0)
aws-sdk-core (~> 3, >= 3.71.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.60.1)
Expand Down Expand Up @@ -137,9 +137,9 @@ GEM
bootsnap (1.4.5)
msgpack (~> 1.0)
builder (3.2.4)
byebug (11.0.1)
byebug (11.1.1)
cancancan (2.3.0)
capybara (3.30.0)
capybara (3.31.0)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
Expand All @@ -151,7 +151,7 @@ GEM
activesupport
citeproc (1.0.10)
namae (~> 1.0)
citeproc-ruby (1.1.10)
citeproc-ruby (1.1.12)
citeproc (~> 1.0, >= 1.0.9)
csl (~> 1.5)
coderay (1.1.2)
Expand All @@ -169,15 +169,16 @@ GEM
sort_alphabetical (~> 1.0)
crack (0.4.3)
safe_yaml (~> 1.0.0)
crass (1.0.5)
crass (1.0.6)
crawler_detect (0.1.11)
csl (1.5.1)
namae (~> 1.0)
csl-styles (1.0.1.10)
csl (~> 1.0)
css_parser (1.7.1)
addressable
dalli (2.7.10)
database_cleaner (1.7.0)
database_cleaner (1.8.1)
debug_inspector (0.0.3)
diff-lcs (1.3)
diffy (3.3.0)
Expand Down Expand Up @@ -230,7 +231,7 @@ GEM
faraday (>= 0.15)
fast_jsonapi (1.5)
activesupport (>= 4.2)
ffi (1.11.3)
ffi (1.12.1)
flipper (0.17.2)
flipper-active_support_cache_store (0.17.2)
activesupport (>= 4.2, < 7)
Expand All @@ -241,7 +242,7 @@ GEM
globalid (0.4.2)
activesupport (>= 4.2.0)
google-protobuf (3.10.0.rc.1)
graphql (1.9.17)
graphql (1.9.19)
graphql-batch (0.4.2)
graphql (>= 1.3, < 2)
promise.rb (~> 0.7.2)
Expand All @@ -257,7 +258,7 @@ GEM
htmlentities (4.3.4)
http-cookie (1.0.3)
domain_name (~> 0.5)
i18n (1.8.1)
i18n (1.8.2)
concurrent-ruby (~> 1.0)
i18n_data (0.8.0)
iso8601 (0.9.1)
Expand All @@ -280,19 +281,20 @@ GEM
oj (~> 3)
optimist (~> 3)
jwt (2.2.1)
kaminari (1.1.1)
kaminari (1.2.0)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.1.1)
kaminari-activerecord (= 1.1.1)
kaminari-core (= 1.1.1)
kaminari-actionview (1.1.1)
kaminari-actionview (= 1.2.0)
kaminari-activerecord (= 1.2.0)
kaminari-core (= 1.2.0)
kaminari-actionview (1.2.0)
actionview
kaminari-core (= 1.1.1)
kaminari-activerecord (1.1.1)
kaminari-core (= 1.2.0)
kaminari-activerecord (1.2.0)
activerecord
kaminari-core (= 1.1.1)
kaminari-core (1.1.1)
kaminari-core (= 1.2.0)
kaminari-core (1.2.0)
latex-decode (0.3.1)
lhm (2.2.0)
link_header (0.0.8)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
Expand All @@ -309,6 +311,8 @@ GEM
loofah (2.4.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
macaddr (1.7.2)
systemu (~> 2.6.5)
mail (2.7.1)
mini_mime (>= 0.1.1)
mailgun-ruby (1.2.0)
Expand All @@ -330,7 +334,7 @@ GEM
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.1009)
mimemagic (0.3.3)
mimemagic (0.3.4)
mini_magick (4.10.1)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
Expand All @@ -346,7 +350,7 @@ GEM
nio4r (2.5.2)
nokogiri (1.10.7)
mini_portile2 (~> 2.4.0)
oj (3.10.0)
oj (3.10.2)
oj_mimic_json (1.0.1)
optimist (3.0.0)
pandoc-ruby (2.0.2)
Expand All @@ -366,7 +370,7 @@ GEM
pwqgen.rb (0.1.0)
docopt (~> 0.5)
sysrandom
rack (2.1.1)
rack (2.1.2)
rack-accept (0.4.5)
rack (>= 0.4)
rack-cors (1.1.1)
Expand Down Expand Up @@ -445,6 +449,8 @@ GEM
rspec-expectations (3.9.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-graphql_matchers (1.1)
graphql (>= 1.8, < 2.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
Expand All @@ -466,7 +472,7 @@ GEM
unicode-display_width (>= 1.4.0, < 1.7)
rubocop-performance (1.5.2)
rubocop (>= 0.71.0)
rubocop-rails (2.4.1)
rubocop-rails (2.4.2)
rack (>= 1.1)
rubocop (>= 0.72.0)
ruby-enum (0.7.2)
Expand Down Expand Up @@ -509,9 +515,12 @@ GEM
regexp_parser (~> 1.3, >= 1.3.0)
strip_attributes (1.9.0)
activemodel (>= 3.0, < 7.0)
strong_migrations (0.6.1)
activerecord (>= 5)
sxp (1.1.0)
rdf (~> 3.1)
sysrandom (1.0.5)
systemu (2.6.5)
temple (0.8.2)
test-prof (0.10.2)
thor (0.20.3)
Expand All @@ -527,10 +536,12 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.7.6)
unicode-display_width (1.6.0)
unicode-display_width (1.6.1)
unicode_utils (1.4.0)
uuid (2.3.9)
macaddr (~> 1.0)
vcr (3.0.3)
webmock (3.7.6)
webmock (3.8.0)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
Expand All @@ -546,7 +557,7 @@ PLATFORMS
DEPENDENCIES
aasm (~> 5.0, >= 5.0.1)
active_model_serializers (~> 0.10.0)
apollo-federation (~> 0.5.1)
apollo-federation (~> 1.0)
audited (~> 4.8)
aws-sdk-s3
aws-sdk-sqs (~> 1.3)
Expand All @@ -564,6 +575,7 @@ DEPENDENCIES
commonmarker (~> 0.17.9)
countries (~> 2.1, >= 2.1.2)
country_select (~> 3.1)
crawler_detect
dalli (~> 2.7, >= 2.7.6)
database_cleaner
diffy (~> 3.2, >= 3.2.1)
Expand Down Expand Up @@ -593,6 +605,7 @@ DEPENDENCIES
jsonlint (~> 0.3.0)
jwt
kaminari (~> 1.0, >= 1.0.1)
lhm (~> 2.2)
listen (>= 3.0.5, < 3.2)
lograge (~> 0.11.2)
logstash-event (~> 1.2, >= 1.2.02)
Expand All @@ -611,6 +624,7 @@ DEPENDENCIES
rails (~> 5.2.0)
rake (~> 12.0)
rspec-benchmark (~> 0.4.0)
rspec-graphql_matchers (~> 1.1)
rspec-rails (~> 3.8, >= 3.8.2)
rubocop (~> 0.77.0)
rubocop-performance (~> 1.5, >= 1.5.1)
Expand All @@ -627,8 +641,10 @@ DEPENDENCIES
sprockets (~> 3.7, >= 3.7.2)
string_pattern
strip_attributes (~> 1.8)
strong_migrations (~> 0.6.0)
test-prof (~> 0.10.2)
turnout (~> 2.5)
uuid (~> 2.3, >= 2.3.9)
vcr (~> 3.0.3)
webmock (~> 3.1)

Expand Down
8 changes: 8 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ def set_jsonp_format
end
end

def detect_crawler
#### Crawlers shound't be making queires
if request.is_crawler? && params[:query].present?
render json: {}, status: :not_found
end
end


def set_consumer_header
if current_user
response.headers['X-Credential-Username'] = current_user.uid
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/client_prefixes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def create

render json: ClientPrefixSerializer.new(@client_prefix, options).serialized_json, status: :created
else
logger.error @client_prefix.errors.inspect
Rails.logger.error @client_prefix.errors.inspect
render json: serialize_errors(@client_prefix.errors), status: :unprocessable_entity
end
end
Expand Down
17 changes: 9 additions & 8 deletions app/controllers/clients_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def create

render json: ClientSerializer.new(@client, options).serialized_json, status: :created
else
logger.error @client.errors.inspect
Rails.logger.error @client.errors.inspect
render json: serialize_errors(@client.errors), status: :unprocessable_entity
end
end
Expand All @@ -129,7 +129,7 @@ def update

render json: ClientSerializer.new(@client, options).serialized_json, status: :ok
else
logger.error @client.errors.inspect
Rails.logger.error @client.errors.inspect
render json: serialize_errors(@client.errors), status: :unprocessable_entity
end
end
Expand All @@ -140,13 +140,13 @@ def destroy
if @client.dois.present?
message = "Can't delete client that has DOIs."
status = 400
logger.warn message
Rails.logger.warn message
render json: { errors: [{ status: status.to_s, title: message }] }.to_json, status: status
elsif @client.update(is_active: nil, deleted_at: Time.zone.now)
@client.send_delete_email unless Rails.env.test?
head :no_content
else
logger.error @client.errors.inspect
Rails.logger.error @client.errors.inspect
render json: serialize_errors(@client.errors), status: :unprocessable_entity
end
end
Expand All @@ -173,16 +173,17 @@ def set_include

def set_client
@client = Client.where(symbol: params[:id]).where(deleted_at: nil).first
fail ActiveRecord::RecordNotFound unless @client.present?
fail ActiveRecord::RecordNotFound if @client.blank?
end

private

def safe_params
fail JSON::ParserError, "You need to provide a payload following the JSONAPI spec" unless params[:data].present?
fail JSON::ParserError, "You need to provide a payload following the JSONAPI spec" if params[:data].blank?

ActiveModelSerializers::Deserialization.jsonapi_parse!(
params, only: [:symbol, :name, "systemEmail", "contactEmail", :domains, :provider, :url, "repositoryType", { "repositoryType" => [] }, :description, :language, { language: [] }, "alternateName", :software, "targetId", "isActive", "passwordInput", "clientType", :re3data, :opendoar, :issn, { issn: [:issnl, :electronic, :print] }, :certificate, { certificate: [] }, "serviceContact", { "serviceContact": [:email, "givenName", "familyName"] }, "salesforceId"],
keys: { "systemEmail" => :system_email, "contactEmail" => :system_email, "salesforceId" => :salesforce_id, "targetId" => :target_id, "isActive" => :is_active, "passwordInput" => :password_input, "clientType" => :client_type, "alternateName" => :alternate_name, "repositoryType" => :repository_type, "serviceContact" => :service_contact }
params, only: [:symbol, :name, "systemEmail", "contactEmail", "globusUuid", :domains, :provider, :url, "repositoryType", { "repositoryType" => [] }, :description, :language, { language: [] }, "alternateName", :software, "targetId", "isActive", "passwordInput", "clientType", :re3data, :opendoar, :issn, { issn: [:issnl, :electronic, :print] }, :certificate, { certificate: [] }, "serviceContact", { "serviceContact": [:email, "givenName", "familyName"] }, "salesforceId"],
keys: { "systemEmail" => :system_email, "contactEmail" => :system_email, "globusUuid" => :globus_uuid, "salesforceId" => :salesforce_id, "targetId" => :target_id, "isActive" => :is_active, "passwordInput" => :password_input, "clientType" => :client_type, "alternateName" => :alternate_name, "repositoryType" => :repository_type, "serviceContact" => :service_contact }
)
end
end
Loading

0 comments on commit 88c2d5e

Please sign in to comment.