dmp-dynamo_adapter 0.2.9 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dmp/dynamo_adapter.rb +9 -5
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d66690b743822deb2db2a047370660b2cd7ec3206844534facbaf04f7f98474c
4
- data.tar.gz: a2d9f06124324415cb5128d6f9f11b305c70d14656788fc38fe4f72bf9af1bc1
3
+ metadata.gz: e6591d15b252c3b6252d1bae91ea019912b62971f05edab4a7ece2cbd9d4a1b1
4
+ data.tar.gz: 8ac48813d44b7afb0d7cf388a707cb6571ec1b57013b829e68d7f3a7d5c6588e
5
5
  SHA512:
6
- metadata.gz: aaba013e38394e8f547a2002eb7c27b9fc9101f950fb53c0880b71c8cb57815dc2459fc65a262d09f1856af73a6ab7f5a3d1bbe15593985845f58c6f7a5bf85a
7
- data.tar.gz: 650f1918d18c4408b25b732a18805b05ff11cb45e41a6aaeaf823d54954fbb4e7805edf60437ef2030348402d77770866787c8a574f9a155f97c77bd9b42a8f6
6
+ metadata.gz: 638372a06477483b5860fcfcea5e7a57c8d47042555871a3c65ded656e23b175b0d426f8138abfa7677f1ca8a9df42fe3c8882e45e897f7c58a5c7c88e08d1ba
7
+ data.tar.gz: 2283314e1c73399d762f06fc3b1e51aeee7f622e617f85cc45a55c0bfdd2e3225e9471bf308e26ed6a966df5a2e8e2926332fab877d227a6df746cea68090f97
@@ -70,7 +70,7 @@ p "FINDING BY PK: PK - #{p_key.inspect} / SK - #{s_key.inspect}"
70
70
  return_consumed_capacity: @debug_mode ? 'TOTAL' : 'NONE'
71
71
  }
72
72
  )
73
- return { status: 404, error: MSG_NOT_FOUND } if response[:item].nil?
73
+ return { status: 404, error: MSG_NOT_FOUND } if response[:item].nil? || response[:item].empty?
74
74
 
75
75
  { status: 200, items: [response[:item]] }
76
76
  rescue Aws::Errors::ServiceError => e
@@ -129,11 +129,14 @@ p "PUTTING ITEM:"
129
129
  return_consumed_capacity: @debug_mode ? 'TOTAL' : 'NONE'
130
130
  }
131
131
  )
132
+ # Fetch the newly created record
133
+ response = find_by_pk(p_key: p_key, s_key: Dmp::MetadataHandler::LATEST_VERSION)
134
+ return { status: 500, error: MSG_DEFAULT } unless response[:status] == 200
132
135
 
133
136
  p 'CREATED!?'
134
- pp response.data
137
+ pp response[:items]
135
138
 
136
- { status: 201, items: [response.data] }
139
+ { status: 201, items: response[:items] }
137
140
  rescue Aws::DynamoDB::Errors::DuplicateItemException
138
141
  { status: 405, error: MSG_EXISTS }
139
142
  rescue Aws::Errors::ServiceError => e
@@ -176,7 +179,7 @@ p ''
176
179
 
177
180
  json = splice_json(original_version: version_result[:items].first&.item, new_version: json)
178
181
 
179
- p ''
182
+ # p ''
180
183
  p "AFTER:"
181
184
  pp json
182
185
 
@@ -253,7 +256,8 @@ pp json
253
256
  # Attempt to find the DMP item by its 'is_metadata_for' :dmproadmap_related_identifier
254
257
  # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
255
258
  def find_by_dmphub_provenance_identifier(json:)
256
- return { status: 400, error: MSG_DEFAULT } if json.nil? || json.fetch('dmp_id', {})['identifier'].nil?
259
+ return { status: 400, error: MSG_DEFAULT } if json.nil? ||
260
+ json.fetch('dmp_id', {})['identifier'].nil?
257
261
 
258
262
  p "FINDING BY PROVENANCE ID: #{json['dmp_id']['identifier']}"
259
263
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dmp-dynamo_adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - briri