dmp-dynamo_adapter 0.2.0 → 0.2.1

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 +11 -9
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9418816d26847581bce0424f326d1b7d65947b2aa3df952c2d8904984229b18c
4
- data.tar.gz: 3e7a9d4819f987dc3ae51a699b88321182d28705d776e48780aedba1d5995412
3
+ metadata.gz: 4c4c901b97437913b47803234f1f6bd80dfe048e307c452ce80b174f465d6de2
4
+ data.tar.gz: f5583c6531e487250ba8ccb0acf7e600a9ca46f7e8fee702bbc35bc5085e7198
5
5
  SHA512:
6
- metadata.gz: 9abe8d680a8dce95cf71d50e14b8fc9c954bb04bdaaa3d080b80dbb639b4f098c7c5b976610a7bff5a37c7ed48c68f330b4e315df93663ec48ffb3a5d2a39119
7
- data.tar.gz: 1378240d137ae3afd8e089d0337d2322d8a8406fc93d3027b14870c6a2a0f0c15087b7b06bd5dd5f158ef93996e21103f0c4488cf4eae77d6cf3607cc8159931
6
+ metadata.gz: 11246b4c0a980ffd9b4b43b4e9566f1ed29dd4f6db4068a96539cbd5d615bae24a1d720efba00a1bbc54ed3c38fdfa2b0405fd69ce6f1c6a0e2cdd6b73cf4383
7
+ data.tar.gz: 9fa961d5cf6405334791cebb57713265dccf5856d8bb853cefa37f0d0a2ab2040dfc88d6678718fae15603c82253d37d26df59d721c69edce529076e5ce0557b
@@ -70,9 +70,6 @@ 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
-
74
- pp response.data
75
-
76
73
  return { status: 404, error: MSG_NOT_FOUND } if response[:item].nil?
77
74
 
78
75
  { status: 200, items: [response[:item]] }
@@ -106,9 +103,6 @@ pp response.data
106
103
  json = prepare_json(json: json)
107
104
  return { status: 400, error: MSG_DEFAULT } if json.nil? || @provenance.nil?
108
105
 
109
- p "FINDING BY JSON"
110
- pp json
111
-
112
106
  # Try to find it first
113
107
  result = find_by_json(json: json)
114
108
  return { status: 500, error: MSG_DEFAULT } if result[:status] == 500
@@ -128,7 +122,11 @@ pp json
128
122
  return_consumed_capacity: @debug_mode ? 'TOTAL' : 'NONE'
129
123
  }
130
124
  )
131
- { status: 201, items: response.items.map(&:item).compact.uniq }
125
+
126
+ p 'CREATED!?'
127
+ pp response.data
128
+
129
+ { status: 201, items: [response.data] }
132
130
  rescue Aws::DynamoDB::Errors::DuplicateItemException
133
131
  { status: 405, error: MSG_EXISTS }
134
132
  rescue Aws::Errors::ServiceError => e
@@ -269,10 +267,14 @@ p "FINDING BY PROVENANCE ID: #{json['dmp_id']['identifier']}"
269
267
  return_consumed_capacity: @debug_mode ? 'TOTAL' : 'NONE'
270
268
  }
271
269
  )
272
- return { status: 404, error: MSG_NOT_FOUND } if response.nil? || response.items.empty?
270
+
271
+ pp response.data
272
+
273
+ return { status: 404, error: MSG_NOT_FOUND } if response.nil? || response[:Count] <= 0
273
274
 
274
275
  # If we got a hit, fetch the DMP and return it.
275
- find_by_pk(p_key: response.items.first.item[:PK])
276
+ find_by_pk(p_key: response.fetch(:LastEvaluatedKey, {})[:HashKeyElement],
277
+ s_key: response.fetch(:LastEvaluatedKey, {})[:RangeKeyElement])
276
278
  rescue Aws::Errors::ServiceError => e
277
279
  { status: 500, error: "#{MSG_DEFAULT} - #{e.message}" }
278
280
  end
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.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - briri