git-fit 0.8.7 → 0.8.8
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 -0
- data/lib/git_fit/cli/sync.rb +15 -14
- 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: 0547b3cc3e8f1c34bbcb472bde62fcb97a24a8f9d7923021e3d7c1acea6072b8
|
|
4
|
+
data.tar.gz: 077211f324433c5e720d1bb57d5a9836805e349baaa0572278e43709fc345722
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 11c4a47b9faa967b2b6e9c0c393a9f43220e3c1bf01a949951087355ad45d770bcc15f7af8700ee8c5a24ca244b6b150738ac8b752933b3b6e8016c53e6bd222
|
|
7
|
+
data.tar.gz: 269d0e18280295248204b860366f8d8213a5b549a09e5c39a224ddd54c4123715d1adada1b84ddbad56e694bc07c84a196b50232738e3123908e4f41684f7552
|
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)
|
|
@@ -80,6 +83,7 @@ module GitFit
|
|
|
80
83
|
say_status :done, "gpx: #{count} activities", :green
|
|
81
84
|
end
|
|
82
85
|
count
|
|
86
|
+
checkpoint_db(db) if options[:checkpoint]
|
|
83
87
|
rescue StandardError => e
|
|
84
88
|
say_status :error, "gpx: #{e.message}", :red
|
|
85
89
|
0
|
|
@@ -88,6 +92,7 @@ module GitFit
|
|
|
88
92
|
|
|
89
93
|
desc 'tcx', 'Import TCX files from data/import/tcx/'
|
|
90
94
|
option :activity, type: :array, desc: 'Filter by sport type', aliases: '--act'
|
|
95
|
+
option :checkpoint, type: :boolean, desc: 'Run WAL checkpoint after import'
|
|
91
96
|
def tcx
|
|
92
97
|
config = GitFit::Config.new
|
|
93
98
|
conn = GitFit::DB::Connection.new(config.db_path)
|
|
@@ -111,6 +116,7 @@ module GitFit
|
|
|
111
116
|
say_status :done, "tcx: #{count} activities", :green
|
|
112
117
|
end
|
|
113
118
|
count
|
|
119
|
+
checkpoint_db(db) if options[:checkpoint]
|
|
114
120
|
rescue StandardError => e
|
|
115
121
|
say_status :error, "tcx: #{e.message}", :red
|
|
116
122
|
0
|
|
@@ -119,6 +125,7 @@ module GitFit
|
|
|
119
125
|
|
|
120
126
|
desc 'fit', 'Import FIT files from data/import/fit/'
|
|
121
127
|
option :activity, type: :array, desc: 'Filter by sport type', aliases: '--act'
|
|
128
|
+
option :checkpoint, type: :boolean, desc: 'Run WAL checkpoint after import'
|
|
122
129
|
def fit
|
|
123
130
|
config = GitFit::Config.new
|
|
124
131
|
conn = GitFit::DB::Connection.new(config.db_path)
|
|
@@ -142,6 +149,7 @@ module GitFit
|
|
|
142
149
|
say_status :done, "fit: #{count} activities", :green
|
|
143
150
|
end
|
|
144
151
|
count
|
|
152
|
+
checkpoint_db(db) if options[:checkpoint]
|
|
145
153
|
rescue StandardError => e
|
|
146
154
|
say_status :error, "fit: #{e.message}", :red
|
|
147
155
|
0
|
|
@@ -150,6 +158,7 @@ module GitFit
|
|
|
150
158
|
|
|
151
159
|
desc 'apple_health', 'Import from Apple Health export.zip'
|
|
152
160
|
option :activity, type: :array, desc: 'Filter by sport type', aliases: '--act'
|
|
161
|
+
option :checkpoint, type: :boolean, desc: 'Run WAL checkpoint after import'
|
|
153
162
|
def apple_health
|
|
154
163
|
config = GitFit::Config.new
|
|
155
164
|
conn = GitFit::DB::Connection.new(config.db_path)
|
|
@@ -172,6 +181,7 @@ module GitFit
|
|
|
172
181
|
say_status :done, "apple_health: #{count} activities", :green
|
|
173
182
|
end
|
|
174
183
|
count
|
|
184
|
+
checkpoint_db(db) if options[:checkpoint]
|
|
175
185
|
rescue StandardError => e
|
|
176
186
|
say_status :error, "apple_health: #{e.message}", :red
|
|
177
187
|
0
|
data/lib/git_fit/cli/sync.rb
CHANGED
|
@@ -22,20 +22,21 @@ module GitFit
|
|
|
22
22
|
(builtin + configured).uniq
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
runner = GitFit::Sync::Runner.new(
|
|
26
|
+
sources: sources,
|
|
27
|
+
db: db,
|
|
28
|
+
config: git_fit_config,
|
|
29
|
+
activity_filter: filter,
|
|
30
|
+
privacy: privacy,
|
|
31
|
+
num_workers: git_fit_config.dig('sync', 'workers') || 3,
|
|
32
|
+
time_budget: git_fit_config.dig('sync', 'time_budget'),
|
|
33
|
+
total_timeout: git_fit_config.dig('sync', 'total_timeout')
|
|
34
|
+
)
|
|
35
|
+
runner.run
|
|
36
|
+
checkpoint_db(db) if options[:checkpoint]
|
|
37
|
+
rescue StandardError => e
|
|
38
|
+
say_status :error, e.message, :red
|
|
39
|
+
end
|
|
39
40
|
end
|
|
40
41
|
end
|
|
41
42
|
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