spree_cm_commissioner 2.8.15.pre.pre5 → 2.8.15.pre.pre6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 73090be1ea7e7e7c8750a9daebfb580d17ba059747fee8aca5e3ed666309209e
|
|
4
|
+
data.tar.gz: 65bf74aadc5710501fbd4e5272e346e4e9cceaf2942bf851d10a9e369c7f5b45
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 759dd1163e66fb130413150e6ad6f231a4f80c143da0cb8abad700dba2e5b93d79f0afeee353ada380be9accbd7fdd037af3a3e827fcdf2d3c149a89785564cb
|
|
7
|
+
data.tar.gz: 25000ede0135e08be28dfeb9b40ec5bc91279975805b6a06316edaecd28a9f9aee8933d746c0cea51c5a2a2ae462121a03effbf0ad1875524cff15b858d712eb
|
data/Gemfile.lock
CHANGED
|
@@ -11,16 +11,21 @@ module SpreeCmCommissioner
|
|
|
11
11
|
|
|
12
12
|
ActiveRecord::Base.transaction do
|
|
13
13
|
voting_credit = find_or_create_credit
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
total_paid_vote_credits = unallocated_line_items.reject { |li| li.product.claimable_vote_package }.sum do |line_item|
|
|
16
|
+
SpreeCmCommissioner::VotingCredits::CreditCalculator.new(line_item).call
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
total_free_vote_credits = unallocated_line_items.select { |li| li.product.claimable_vote_package }.sum do |line_item|
|
|
15
20
|
SpreeCmCommissioner::VotingCredits::CreditCalculator.new(line_item).call
|
|
16
21
|
end
|
|
17
|
-
total_paid_vote_credits = allocations.sum
|
|
18
22
|
|
|
19
23
|
# Use with_lock to ensure we have a lock on the voting credit record while we:
|
|
20
24
|
# - Modify data inside the block
|
|
21
25
|
# - Need to prevent race conditions
|
|
22
26
|
voting_credit.with_lock do
|
|
23
27
|
voting_credit.paid_votes_amount += total_paid_vote_credits
|
|
28
|
+
voting_credit.free_votes_amount += total_free_vote_credits
|
|
24
29
|
voting_credit.save!
|
|
25
30
|
end
|
|
26
31
|
|
|
@@ -55,6 +60,24 @@ module SpreeCmCommissioner
|
|
|
55
60
|
.to_a
|
|
56
61
|
end
|
|
57
62
|
|
|
63
|
+
def unallocated_line_items
|
|
64
|
+
return episode_line_items if @order.user_id.blank?
|
|
65
|
+
|
|
66
|
+
episode_line_items.reject do |line_item|
|
|
67
|
+
next false unless line_item.price.zero?
|
|
68
|
+
|
|
69
|
+
scope = line_item.claim_scope
|
|
70
|
+
next false if scope.nil?
|
|
71
|
+
|
|
72
|
+
SpreeCmCommissioner::Claim.free_claimed?(
|
|
73
|
+
user_id: @order.user_id,
|
|
74
|
+
product_id: line_item.product.id,
|
|
75
|
+
claimable_id: scope[:claimable_id],
|
|
76
|
+
claimable_type: scope[:claimable_type]
|
|
77
|
+
)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
58
81
|
def find_or_create_credit
|
|
59
82
|
SpreeCmCommissioner::VotingCredit.active.find_or_create_by!(
|
|
60
83
|
tenant_id: @order.tenant_id,
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_cm_commissioner
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.8.15.pre.
|
|
4
|
+
version: 2.8.15.pre.pre6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- You
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-06-
|
|
11
|
+
date: 2026-06-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: spree
|