<commit_before>class EventResultService
  def initialize(track, round, wind_cancellation: false)
    @track = track
    @event = round.event
    @task = round.discipline.to_sym
    @wind_cancellation = wind_cancellation
  end

  def calculate
    points = subtract_wind(track_points) if @wind_cancellation

    track_segment = WindowRangeFinder.new(track_points).execute(
      from_altitude: @event.range_from,
      to_altitude: @event.range_to)

    track_segment.public_send(@task)
  rescue WindowRangeFinder::ValueOutOfRange
    return 0
  end

  private

  attr_reader :track

  def subtract_wind(points)
    start_time = points.first[:gps_time].beginning_of_hour
    weather_data = @event.place.weather_data.for_time(start_time)

    wind_data = WindCancellation::WindData.new(weather_data)
    points = WindCancellation::WindSubtraction.new(points, wind_data).execute
  end

  def track_points
    @track_points ||= PointsQuery.execute(
      track,
      trimmed: true,
      only: %i[gps_time altitude latitude longitude]
    )
  end
end<commit_msg>add time_diff to query points<commit_after>class EventResultService
  def initialize(track, round, wind_cancellation: false)
    @track = track
    @event = round.event
    @task = round.discipline.to_sym
    @wind_cancellation = wind_cancellation
  end

  def calculate
    points = subtract_wind(track_points) if @wind_cancellation

    track_segment = WindowRangeFinder.new(track_points).execute(
      from_altitude: @event.range_from,
      to_altitude: @event.range_to)

    track_segment.public_send(@task)
  rescue WindowRangeFinder::ValueOutOfRange
    return 0
  end

  private

  attr_reader :track

  def subtract_wind(points)
    start_time = points.first[:gps_time].beginning_of_hour
    weather_data = @event.place.weather_data.for_time(start_time)

    wind_data = WindCancellation::WindData.new(weather_data)
    points = WindCancellation::WindSubtraction.new(points, wind_data).execute
  end

  def track_points
    @track_points ||= PointsQuery.execute(
      track,
      trimmed: true,
      only: %i[gps_time time_diff altitude latitude longitude]
    )
  end
end
{'fraction_non_alphanumeric': 0.08115671641791045, 'fraction_numerical': 0.0009328358208955224, 'mean_word_length': 4.107142857142857, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2215168', 'n_tokens_mistral': 716, 'n_tokens_neox': 683, 'n_words': 130}