Workaround to fix #6032 and handle changes in expected results from wikidata-diff-analyzer brought by the changes to the code logic in the wikidata-diff-analyzer gem.
First error is fixed by wrapping analyzing of revisions in a begin-rescue to handle errors from WikidataDiffAnalyzer (logs the error but does not break the process) and adding a guard statement to skip a revision if no analyzed revision available for its rev_id.
NoMethodError: undefined method `each' for nil:NilClass
revisions.each do |revision|
^^^^^
2024-11-08T18:39:34.328Z pid=259956 tid=2qjk WARN: /usr/share/rvm/gems/ruby-3.1.2/gems/wikidata-diff-analyzer-2.0.2/lib/wikidata/diff/api.rb:37:in `block in get_revision_contents'
/usr/share/rvm/gems/ruby-3.1.2/gems/wikidata-diff-analyzer-2.0.2/lib/wikidata/diff/api.rb:33:in `each'
/usr/share/rvm/gems/ruby-3.1.2/gems/wikidata-diff-analyzer-2.0.2/lib/wikidata/diff/api.rb:33:in `get_revision_contents'
/// more trace
After implementing that, the next error was resolved by adding a guard statement to skip processing the deserialized_stat if it is nil or false
Before: The update for course_id 10023 failed with the errors above
After: The course was updated succesfully
I tested it on two courses, the buggy course with id 10023, and a random course with id 10022:
course_id 10023:
course_id 10022:
So the added logic should not affect / break the wikidata stats update process.
Note: I had Metrics/ClassLength and Metrics/MethodLength lint errors so I initially tried to shorten the code logic, which actually led to more lint errors so I searched slack and you once said to wrap the whole class in the rubocop special comment to disable a rule for the file, and so I did that.
What this PR does
Workaround to fix #6032 and handle changes in expected results from wikidata-diff-analyzer brought by the changes to the code logic in the wikidata-diff-analyzer gem.
First error is fixed by wrapping analyzing of revisions in a begin-rescue to handle errors from WikidataDiffAnalyzer (logs the error but does not break the process) and adding a guard statement to skip a revision if no analyzed revision available for its rev_id.
Screenshots
Before: The update for course_id 10023 failed with the errors above
After: The course was updated succesfully
I tested it on two courses, the buggy course with id 10023, and a random course with id 10022:
course_id 10023:
course_id 10022:
So the added logic should not affect / break the wikidata stats update process.
Note: I had Metrics/ClassLength and Metrics/MethodLength lint errors so I initially tried to shorten the code logic, which actually led to more lint errors so I searched slack and you once said to wrap the whole class in the rubocop special comment to disable a rule for the file, and so I did that.