AO3-4128-more thorough progress fix #2489

Merged
merged 2 commits into from Jun 28, 2016

2 participants

@shalott
Organization for Transformative Works member
shalott commented Jun 21, 2016 edited

https://otwarchive.atlassian.net/browse/AO3-4128

The progress report was NOT fixed. I've reworked the way it was being done, and also added tests. Now hopefully working for reals. Tests running clean.

Signed-off-by: astolat shalott [email protected]

@shalott shalott fixing the progress again, now with testing
Signed-off-by: astolat shalott <[email protected]>
ecd0043
@houndci-bot houndci-bot commented on the diff Jun 21, 2016
spec/models/potential_match_spec.rb
+
+describe PotentialMatch do
+
+ before do
+ @potential_match = create(:potential_match)
+ @collection = @potential_match.collection
+ @first_signup = @collection.signups.first
+ @last_signup = @collection.signups.last
+ end
+
+ it "should have a progress key" do
+ expect(PotentialMatch.progress_key(@collection)).to include("#{@collection.id}")
+ end
+
+ it "should have a signup key" do
+ expect(PotentialMatch.signup_key(@collection)).to include("#{@collection.id}")

Prefer to_s over string interpolation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on the diff Jun 21, 2016
spec/models/potential_match_spec.rb
@@ -0,0 +1,46 @@
+require 'spec_helper'
+
+describe PotentialMatch do
+
+ before do
+ @potential_match = create(:potential_match)
+ @collection = @potential_match.collection
+ @first_signup = @collection.signups.first
+ @last_signup = @collection.signups.last
+ end
+
+ it "should have a progress key" do
+ expect(PotentialMatch.progress_key(@collection)).to include("#{@collection.id}")

Prefer to_s over string interpolation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on the diff Jun 21, 2016
spec/models/potential_match_spec.rb
@@ -0,0 +1,46 @@
+require 'spec_helper'
+
+describe PotentialMatch do
+

Extra empty line detected at block body beginning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on an outdated diff Jun 21, 2016
factories/challenges.rb
signup.offers.build(pseud_id: signup.pseud_id, collection_id: signup.collection_id)
signup.requests.build(pseud_id: signup.pseud_id, collection_id: signup.collection_id)
end
end
+
+ factory :potential_match do |f|

Unused block argument - f. You can omit the argument if you don't care about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on the diff Jun 21, 2016
app/models/potential_match.rb
@@ -20,8 +20,8 @@ def self.progress_key(collection)
CACHE_PROGRESS_KEY + "#{collection.id}"
end
- def self.byline_key(collection)
- CACHE_BYLINE_KEY + "#{collection.id}"
+ def self.signup_key(collection)
+ CACHE_SIGNUP_KEY + "#{collection.id}"

Prefer to_s over string interpolation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on an outdated diff Jun 21, 2016
app/models/potential_match.rb
@@ -4,7 +4,7 @@ class PotentialMatch < ActiveRecord::Base
ALL = -1
CACHE_PROGRESS_KEY = "potential_match_status_for_"
- CACHE_BYLINE_KEY = "potential_match_bylines_for_"
+ CACHE_SIGNUP_KEY = "potential_match_signups_for_"

Freeze mutable objects assigned to constants.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@houndci-bot houndci-bot commented on the diff Jun 21, 2016
app/models/potential_match.rb
@@ -20,8 +20,8 @@ def self.progress_key(collection)
CACHE_PROGRESS_KEY + "#{collection.id}"
end
- def self.byline_key(collection)
- CACHE_BYLINE_KEY + "#{collection.id}"
+ def self.signup_key(collection)

protected (on line 17) does not make singleton methods protected. Use protected inside a class << self block instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@shalott shalott hound fixes
Signed-off-by: astolat shalott <[email protected]>
141c7ea
@elzj elzj commented on the diff Jun 26, 2016
app/models/potential_match.rb
@@ -104,9 +104,14 @@ def self.generate_in_background(collection_id)
required_types = settings.required_types.map {|t| t.classify}
# treat each signup as a request signup first
- collection.signups.find_each do |signup|
+ # because find_each doesn't give us a consistent order, but we don't necessarily
@elzj
Organization for Transformative Works member
elzj added a note Jun 26, 2016

What ordering problem did you find with find_each? The Rails documentation says: "[Order] is automatically set to ascending on the primary key (“id ASC”) to make the batch ordering work." So I would expect that to do what you want?

@shalott
Organization for Transformative Works member
shalott added a note Jun 27, 2016

Actually, in retrospect I realized the issue was likely because the job-restarting code was causing the process to start over and over on top of itself. However, I think this remains a better way of handling the progress (doesn't break if user changes name/pseud midstream), so would still rather get this in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@zz9pzza zz9pzza merged commit 364d366 into otwcode:master Jun 28, 2016

2 checks passed

Details continuous-integration/travis-ci/pr The Travis CI build passed
hound 5 violations found.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment