Class: Wikipedia::VandalismDetection::Features::TimeInterval
- Defined in:
- lib/wikipedia/vandalism_detection/features/time_interval.rb
Overview
This feature computes the time interval in days between old and new revision.
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#calculate(edit) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/wikipedia/vandalism_detection/features/time_interval.rb', line 11 def calculate(edit) super new_time = DateTime.parse(edit.new_revision.) if edit.old_revision..blank? xml = Wikipedia::api_request({ prop: 'revisions', rvprop: 'timestamp', revids: edit.old_revision.id }) = xml.xpath('//rev/@timestamp').text return Features::MISSING_VALUE if .blank? old_time = DateTime.parse() else old_time = DateTime.parse(edit.old_revision.) end (new_time - old_time).to_f.abs end |