Skip to content

Commit b179f9f

Browse files
docs: add comments to clarify elevation gain and loss handling in migrations regarding smallint
1 parent b60a8ec commit b179f9f

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

lib/teslamate/log.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ defmodule TeslaMate.Log do
291291
not is_nil(p.odometer),
292292
limit: 1
293293

294+
# If the sum of elevation gains exceeds the max value of a smallint (32767), set it to 0.
295+
# If the sum of elevation losses exceeds the max value of a smallint (32767), set it to 0.
294296
elevation_data =
295297
from p1 in subquery(
296298
from p in Position,

priv/repo/migrations/20250613133700_add_and_calculate_elevation_changes.exs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ defmodule TeslaMate.Repo.Migrations.AddAndCalculateElevationChanges do
77
add :descent, :smallint
88
end
99

10+
# If the sum of elevation gains exceeds the max value of a smallint (32767), set it to 0.
11+
# If the sum of elevation losses exceeds the max value of a smallint (32767), set it to 0.
12+
1013
execute """
1114
WITH elevation_changes AS (
1215
SELECT

0 commit comments

Comments
 (0)