mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
15 lines
488 B
Ruby
15 lines
488 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Track < ApplicationRecord
|
|
belongs_to :user
|
|
has_many :points, dependent: :nullify
|
|
|
|
validates :start_at, :end_at, :original_path, presence: true
|
|
validates :distance, :avg_speed, :duration, numericality: { greater_than: 0 }
|
|
validates :elevation_gain, :elevation_loss, :elevation_max, :elevation_min,
|
|
numericality: { greater_than_or_equal_to: 0 }
|
|
|
|
def calculate_path
|
|
Tracks::BuildPath.new(points.pluck(:lonlat)).call
|
|
end
|
|
end
|