git-fit 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/db/migrations/001_full_schema.rb +64 -0
- data/db/migrations/002_iso8601_time_format.rb +54 -0
- data/lib/git_fit/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8a78b1c8fb26ac34a8e0787486abf5778e7dd55ed9e93d7ffbf0232a14e3262c
|
|
4
|
+
data.tar.gz: e4096a9da8f48d42233ec09ee3a1e95559c0b7666d2150fc63e4e5c6ad325c2e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fe156a3b1276d4eeb1ebbee6382640a3e06707114bfb43a1c2170ffb6bd5252140250b6b532daaf500e2553c676dc5340bec58d36ff8e27f77926511fe170f79
|
|
7
|
+
data.tar.gz: 0a24ea2027d9e8baf534f8d587e5aca50ea4dc0e6e78fd5e6c931e0c87b6752dcb5a0e05e55c96272f9994cf5ca05cf95d29e9c8fa7610169161401240000f24
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Sequel.migration do
|
|
2
|
+
up do
|
|
3
|
+
create_table?(:activities) do
|
|
4
|
+
Integer :id, primary_key: true
|
|
5
|
+
String :run_id, null: false, unique: true
|
|
6
|
+
String :name
|
|
7
|
+
Float :distance
|
|
8
|
+
Integer :moving_time
|
|
9
|
+
Integer :elapsed_time
|
|
10
|
+
String :sport_category, null: false, default: "run"
|
|
11
|
+
String :sport_type
|
|
12
|
+
String :start_date
|
|
13
|
+
String :start_date_local
|
|
14
|
+
String :location_country
|
|
15
|
+
String :summary_polyline, text: true
|
|
16
|
+
Float :average_heartrate
|
|
17
|
+
Float :max_heartrate
|
|
18
|
+
Float :average_cadence
|
|
19
|
+
Float :max_cadence
|
|
20
|
+
Float :average_power
|
|
21
|
+
Float :max_power
|
|
22
|
+
Float :average_temperature
|
|
23
|
+
Integer :calories
|
|
24
|
+
Float :average_speed
|
|
25
|
+
Float :elevation_gain
|
|
26
|
+
String :source
|
|
27
|
+
String :duplicate_info, text: true
|
|
28
|
+
String :divisions, text: true
|
|
29
|
+
String :title, text: true
|
|
30
|
+
String :external_id
|
|
31
|
+
DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
|
|
32
|
+
DateTime :updated_at, default: Sequel::CURRENT_TIMESTAMP
|
|
33
|
+
|
|
34
|
+
index :start_date
|
|
35
|
+
index :source
|
|
36
|
+
index :sport_category
|
|
37
|
+
index :external_id
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
create_table?(:dedup_groups) do
|
|
41
|
+
primary_key :id
|
|
42
|
+
String :group_id, null: false, unique: true
|
|
43
|
+
DateTime :created_at
|
|
44
|
+
DateTime :updated_at
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
create_table?(:dedup_group_members) do
|
|
48
|
+
primary_key :id
|
|
49
|
+
foreign_key :group_id, :dedup_groups, type: String, key: :group_id, null: false
|
|
50
|
+
String :run_id, null: false
|
|
51
|
+
String :source
|
|
52
|
+
String :flag
|
|
53
|
+
Float :confidence
|
|
54
|
+
unique [:group_id, :run_id]
|
|
55
|
+
index :run_id
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
down do
|
|
60
|
+
drop_table?(:dedup_group_members)
|
|
61
|
+
drop_table?(:dedup_groups)
|
|
62
|
+
drop_table?(:activities)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
Sequel.migration do
|
|
2
|
+
up do
|
|
3
|
+
rows = self[:activities].all
|
|
4
|
+
|
|
5
|
+
rows.each do |row|
|
|
6
|
+
updates = {}
|
|
7
|
+
|
|
8
|
+
# Detect format: ISO 8601 contains "T", naive format does not
|
|
9
|
+
sd = row[:start_date]
|
|
10
|
+
if sd && sd.is_a?(String) && !sd.include?("T")
|
|
11
|
+
t = Time.parse(sd) rescue nil
|
|
12
|
+
if t
|
|
13
|
+
case row[:source]
|
|
14
|
+
when "apple_health"
|
|
15
|
+
# Apple Health stored +0800 local time as naive "2026-06-25 19:49:17"
|
|
16
|
+
# Parse as local (+0800) then convert to UTC ISO 8601
|
|
17
|
+
local_t = Time.parse(sd + " +0800") rescue nil
|
|
18
|
+
updates[:start_date] = local_t.utc.iso8601 if local_t
|
|
19
|
+
else
|
|
20
|
+
# All other sources stored UTC naive "2026-06-25 11:49:17"
|
|
21
|
+
# Parse as UTC then output ISO 8601
|
|
22
|
+
utc_t = Time.parse(sd + " UTC") rescue nil
|
|
23
|
+
updates[:start_date] = utc_t.iso8601 if utc_t
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
sdl = row[:start_date_local]
|
|
29
|
+
if sdl && sdl.is_a?(String) && !sdl.include?("T")
|
|
30
|
+
t = Time.parse(sdl) rescue nil
|
|
31
|
+
if t
|
|
32
|
+
case row[:source]
|
|
33
|
+
when "strava", "igpsport"
|
|
34
|
+
# These stores proper local time, preserve as ISO 8601 with offset
|
|
35
|
+
local_t = Time.parse(sdl + " +0800") rescue nil
|
|
36
|
+
updates[:start_date_local] = local_t.iso8601 if local_t
|
|
37
|
+
else
|
|
38
|
+
# Same as start_date (UTC)
|
|
39
|
+
utc_t = Time.parse(sdl + " UTC") rescue nil
|
|
40
|
+
updates[:start_date_local] = utc_t.iso8601 if utc_t
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
self[:activities].where(run_id: row[:run_id]).update(updates) unless updates.empty?
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
down do
|
|
50
|
+
# One-way migration: cannot automatically revert ISO 8601 → naive
|
|
51
|
+
# because timezone info would be silently lost.
|
|
52
|
+
# To rollback: restore from DB backup or re-import.
|
|
53
|
+
end
|
|
54
|
+
end
|
data/lib/git_fit/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: git-fit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lax
|
|
@@ -186,6 +186,8 @@ executables:
|
|
|
186
186
|
extensions: []
|
|
187
187
|
extra_rdoc_files: []
|
|
188
188
|
files:
|
|
189
|
+
- db/migrations/001_full_schema.rb
|
|
190
|
+
- db/migrations/002_iso8601_time_format.rb
|
|
189
191
|
- exe/git-fit
|
|
190
192
|
- lib/git-fit.rb
|
|
191
193
|
- lib/git_fit/cli.rb
|