quarantine 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/quarantine/databases/dynamo_db.rb +23 -10
- data/lib/quarantine/test.rb +9 -0
- data/lib/quarantine/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aaede44e051f9b183da284c82c86ae341ac4361bb8c36ba12f7cb11c4fc47350
|
4
|
+
data.tar.gz: dce85fa1bac7d33224b907e53ed570763b87cbd783ae983d88e7dc563b0b0db0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc724bcd18323c374bd1e8c5ae472db1579d9334e4d050c352058902981488a5659b542c26ba464e88d47bb102efb20ce9faa5990ba098225200cab11324792f
|
7
|
+
data.tar.gz: 63d3dbeb70b087ba783a925cd57d1cf76488fbaae6819b53509fafe3b6609e2fb0e126f3ae03e70f00ebfe358cd93e42e4341bd44790b4773e6cf7c3d1921655
|
data/CHANGELOG.md
CHANGED
@@ -16,7 +16,7 @@ class Quarantine
|
|
16
16
|
|
17
17
|
def scan(table_name)
|
18
18
|
begin
|
19
|
-
result = dynamodb.scan(
|
19
|
+
result = dynamodb.scan(table_name: table_name)
|
20
20
|
rescue Aws::DynamoDB::Errors::ServiceError
|
21
21
|
raise Quarantine::DatabaseError
|
22
22
|
end
|
@@ -24,17 +24,32 @@ class Quarantine
|
|
24
24
|
result&.items
|
25
25
|
end
|
26
26
|
|
27
|
-
def batch_write_item(table_name, items, additional_attributes = {})
|
27
|
+
def batch_write_item(table_name, items, additional_attributes = {}, dedup_keys = %w[id full_description])
|
28
|
+
return if items.empty?
|
29
|
+
|
30
|
+
# item_a is a duplicate of item_b if all values for each dedup_key in both item_a and item_b match
|
31
|
+
is_a_duplicate = ->(item_a, item_b) { dedup_keys.all? { |key| item_a[key] == item_b[key] } }
|
32
|
+
|
33
|
+
scanned_items = scan(table_name)
|
34
|
+
|
35
|
+
deduped_items = items.reject do |item|
|
36
|
+
scanned_items.any? do |scanned_item|
|
37
|
+
is_a_duplicate.call(item.to_string_hash, scanned_item)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
return if deduped_items.empty?
|
42
|
+
|
28
43
|
dynamodb.batch_write_item(
|
29
|
-
|
30
|
-
table_name =>
|
44
|
+
request_items: {
|
45
|
+
table_name => deduped_items.map do |item|
|
31
46
|
{
|
32
47
|
put_request: {
|
33
48
|
item: { **item.to_hash, **additional_attributes }
|
34
49
|
}
|
35
50
|
}
|
36
51
|
end
|
37
|
-
}
|
52
|
+
}
|
38
53
|
)
|
39
54
|
rescue Aws::DynamoDB::Errors::ServiceError
|
40
55
|
raise Quarantine::DatabaseError
|
@@ -42,11 +57,9 @@ class Quarantine
|
|
42
57
|
|
43
58
|
def delete_item(table_name, keys)
|
44
59
|
dynamodb.delete_item(
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
**keys
|
49
|
-
}
|
60
|
+
table_name: table_name,
|
61
|
+
key: {
|
62
|
+
**keys
|
50
63
|
}
|
51
64
|
)
|
52
65
|
rescue Aws::DynamoDB::Errors::ServiceError
|
data/lib/quarantine/test.rb
CHANGED
data/lib/quarantine/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quarantine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flexport Engineering, Eric Zhu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-dynamodb
|
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: '0'
|
93
93
|
requirements: []
|
94
|
-
rubygems_version: 3.0.
|
94
|
+
rubygems_version: 3.0.2
|
95
95
|
signing_key:
|
96
96
|
specification_version: 4
|
97
97
|
summary: Quarantine flaky Ruby Rspec tests
|