git-fit 0.8.7 → 0.8.9
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/lib/git_fit/cli/geo_cli.rb +2 -0
- data/lib/git_fit/cli/import_cli.rb +10 -4
- data/lib/git_fit/cli/sync.rb +2 -1
- data/lib/git_fit/cli.rb +10 -0
- data/lib/git_fit/db/cli.rb +12 -0
- data/lib/git_fit/db/connection.rb +4 -0
- data/lib/git_fit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9aedbd56b7a0006cad60386fa55b030857cef43497e0d798bb334f6ddaf968fb
|
|
4
|
+
data.tar.gz: 526692de645f4cee05b8b61a3bc3018efbaad202c2d342b7376e7a90e1b1f237
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 10c0908e780b6c8f01cc32af8ed20bcc344f197edcf2daeb2f799f99cad78433a7159d15e0b7dffe51bc654fd76c75ebf6e29152a9e8500aa760fb4a85d10b84
|
|
7
|
+
data.tar.gz: e36c0f4b019e587640e220704cc82a05eb4533db5314fabfc9ea32771d0493c198df90fdf8b490ee1293924a39630dc8a8721abde3e4ebbe8233f8e722325f2e
|
data/lib/git_fit/cli/geo_cli.rb
CHANGED
|
@@ -10,6 +10,7 @@ module GitFit
|
|
|
10
10
|
option :strategy, type: :string, aliases: '-s', desc: 'Strategy: proportional|start_end', default: 'proportional'
|
|
11
11
|
option :time, type: :numeric, aliases: '-t', desc: 'Time budget in seconds'
|
|
12
12
|
option :"dry-run", type: :boolean, desc: "Don't write to DB"
|
|
13
|
+
option :checkpoint, type: :boolean, desc: 'Run WAL checkpoint after detect'
|
|
13
14
|
def detect
|
|
14
15
|
config = GitFit::Config.new
|
|
15
16
|
conn = GitFit::DB::Connection.new(config.db_path)
|
|
@@ -26,6 +27,7 @@ module GitFit
|
|
|
26
27
|
dry_run: options[:"dry-run"],
|
|
27
28
|
)
|
|
28
29
|
detector.run
|
|
30
|
+
checkpoint_db(db) if options[:checkpoint]
|
|
29
31
|
rescue StandardError => e
|
|
30
32
|
say_status :error, "Geo detection failed: #{e.message}", :red
|
|
31
33
|
end
|
|
@@ -11,6 +11,7 @@ module GitFit
|
|
|
11
11
|
desc: 'Import source(s) — comma-separated (default: gpx,fit,tcx)'
|
|
12
12
|
option :activity, type: :array, desc: 'Filter by sport type', aliases: '--act'
|
|
13
13
|
option :sport, type: :string, desc: 'Override sport_category for GPX files'
|
|
14
|
+
option :checkpoint, type: :boolean, desc: 'Run WAL checkpoint after import'
|
|
14
15
|
def all
|
|
15
16
|
sources = (options[:source] || 'gpx,fit,tcx').split(',').map(&:strip).map(&:downcase)
|
|
16
17
|
unknown = sources.reject { |s| FILE_SOURCES.include?(s) }
|
|
@@ -48,6 +49,7 @@ module GitFit
|
|
|
48
49
|
else
|
|
49
50
|
say_status :done, "Total: #{total} activities", :green
|
|
50
51
|
end
|
|
52
|
+
checkpoint_db(db) if options[:checkpoint]
|
|
51
53
|
end
|
|
52
54
|
|
|
53
55
|
default_command :all
|
|
@@ -55,6 +57,7 @@ module GitFit
|
|
|
55
57
|
desc 'gpx', 'Import GPX files from data/import/gpx/'
|
|
56
58
|
option :activity, type: :array, desc: 'Filter by sport type', aliases: '--act'
|
|
57
59
|
option :sport, type: :string, desc: 'Override sport_category for GPX files'
|
|
60
|
+
option :checkpoint, type: :boolean, desc: 'Run WAL checkpoint after import'
|
|
58
61
|
def gpx
|
|
59
62
|
config = GitFit::Config.new
|
|
60
63
|
conn = GitFit::DB::Connection.new(config.db_path)
|
|
@@ -79,7 +82,7 @@ module GitFit
|
|
|
79
82
|
else
|
|
80
83
|
say_status :done, "gpx: #{count} activities", :green
|
|
81
84
|
end
|
|
82
|
-
|
|
85
|
+
checkpoint_db(db) if options[:checkpoint]
|
|
83
86
|
rescue StandardError => e
|
|
84
87
|
say_status :error, "gpx: #{e.message}", :red
|
|
85
88
|
0
|
|
@@ -88,6 +91,7 @@ module GitFit
|
|
|
88
91
|
|
|
89
92
|
desc 'tcx', 'Import TCX files from data/import/tcx/'
|
|
90
93
|
option :activity, type: :array, desc: 'Filter by sport type', aliases: '--act'
|
|
94
|
+
option :checkpoint, type: :boolean, desc: 'Run WAL checkpoint after import'
|
|
91
95
|
def tcx
|
|
92
96
|
config = GitFit::Config.new
|
|
93
97
|
conn = GitFit::DB::Connection.new(config.db_path)
|
|
@@ -110,7 +114,7 @@ module GitFit
|
|
|
110
114
|
else
|
|
111
115
|
say_status :done, "tcx: #{count} activities", :green
|
|
112
116
|
end
|
|
113
|
-
|
|
117
|
+
checkpoint_db(db) if options[:checkpoint]
|
|
114
118
|
rescue StandardError => e
|
|
115
119
|
say_status :error, "tcx: #{e.message}", :red
|
|
116
120
|
0
|
|
@@ -119,6 +123,7 @@ module GitFit
|
|
|
119
123
|
|
|
120
124
|
desc 'fit', 'Import FIT files from data/import/fit/'
|
|
121
125
|
option :activity, type: :array, desc: 'Filter by sport type', aliases: '--act'
|
|
126
|
+
option :checkpoint, type: :boolean, desc: 'Run WAL checkpoint after import'
|
|
122
127
|
def fit
|
|
123
128
|
config = GitFit::Config.new
|
|
124
129
|
conn = GitFit::DB::Connection.new(config.db_path)
|
|
@@ -141,7 +146,7 @@ module GitFit
|
|
|
141
146
|
else
|
|
142
147
|
say_status :done, "fit: #{count} activities", :green
|
|
143
148
|
end
|
|
144
|
-
|
|
149
|
+
checkpoint_db(db) if options[:checkpoint]
|
|
145
150
|
rescue StandardError => e
|
|
146
151
|
say_status :error, "fit: #{e.message}", :red
|
|
147
152
|
0
|
|
@@ -150,6 +155,7 @@ module GitFit
|
|
|
150
155
|
|
|
151
156
|
desc 'apple_health', 'Import from Apple Health export.zip'
|
|
152
157
|
option :activity, type: :array, desc: 'Filter by sport type', aliases: '--act'
|
|
158
|
+
option :checkpoint, type: :boolean, desc: 'Run WAL checkpoint after import'
|
|
153
159
|
def apple_health
|
|
154
160
|
config = GitFit::Config.new
|
|
155
161
|
conn = GitFit::DB::Connection.new(config.db_path)
|
|
@@ -171,7 +177,7 @@ module GitFit
|
|
|
171
177
|
else
|
|
172
178
|
say_status :done, "apple_health: #{count} activities", :green
|
|
173
179
|
end
|
|
174
|
-
|
|
180
|
+
checkpoint_db(db) if options[:checkpoint]
|
|
175
181
|
rescue StandardError => e
|
|
176
182
|
say_status :error, "apple_health: #{e.message}", :red
|
|
177
183
|
0
|
data/lib/git_fit/cli/sync.rb
CHANGED
|
@@ -33,8 +33,9 @@ module GitFit
|
|
|
33
33
|
total_timeout: git_fit_config.dig('sync', 'total_timeout')
|
|
34
34
|
)
|
|
35
35
|
runner.run
|
|
36
|
+
checkpoint_db(db) if options[:checkpoint]
|
|
36
37
|
rescue StandardError => e
|
|
37
|
-
|
|
38
|
+
say_status :error, e.message, :red
|
|
38
39
|
end
|
|
39
40
|
end
|
|
40
41
|
end
|
data/lib/git_fit/cli.rb
CHANGED
|
@@ -67,6 +67,7 @@ module GitFit
|
|
|
67
67
|
desc 'sync', 'Sync workout data from a source'
|
|
68
68
|
option :source, type: :string, desc: 'Source name (e.g. lorem)'
|
|
69
69
|
option :activity, type: :array, desc: 'Filter by sport type', aliases: '--act'
|
|
70
|
+
option :checkpoint, type: :boolean, desc: 'Run WAL checkpoint after sync'
|
|
70
71
|
def sync
|
|
71
72
|
super
|
|
72
73
|
end
|
|
@@ -120,6 +121,15 @@ module GitFit
|
|
|
120
121
|
conn.db
|
|
121
122
|
end
|
|
122
123
|
|
|
124
|
+
def checkpoint_db(db)
|
|
125
|
+
result = db.fetch('PRAGMA wal_checkpoint(TRUNCATE)').first
|
|
126
|
+
say_status :checkpoint, "WAL checkpoint: #{result[:checkpointed]} pages", :green
|
|
127
|
+
result
|
|
128
|
+
rescue StandardError => e
|
|
129
|
+
say_status :error, "Checkpoint failed: #{e.message}", :red
|
|
130
|
+
nil
|
|
131
|
+
end
|
|
132
|
+
|
|
123
133
|
def deep_dup(obj)
|
|
124
134
|
case obj
|
|
125
135
|
when Hash then obj.each_with_object({}) { |(k, v), h| h[k] = deep_dup(v) }
|
data/lib/git_fit/db/cli.rb
CHANGED
|
@@ -31,6 +31,18 @@ module GitFit
|
|
|
31
31
|
print ddl
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
|
+
|
|
35
|
+
desc 'checkpoint', 'Run WAL checkpoint (TRUNCATE)'
|
|
36
|
+
def checkpoint
|
|
37
|
+
config = GitFit::Config.new
|
|
38
|
+
conn = GitFit::DB::Connection.new(config.db_path)
|
|
39
|
+
result = conn.checkpoint
|
|
40
|
+
say_status :checkpoint, 'WAL checkpoint complete', :green
|
|
41
|
+
puts " busy=#{result[:busy]} log=#{result[:log]} checkpointed=#{result[:checkpointed]}"
|
|
42
|
+
rescue StandardError => e
|
|
43
|
+
say_status :error, "Checkpoint failed: #{e.message}", :red
|
|
44
|
+
exit(1)
|
|
45
|
+
end
|
|
34
46
|
end
|
|
35
47
|
end
|
|
36
48
|
end
|
data/lib/git_fit/version.rb
CHANGED