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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e97d60b0affcf6dd5199a16b110e62a8a967fcc23e467247123643935ddd0d9
4
- data.tar.gz: 3249a783e16efb8e3d1fc87fae4cebad8e94514478f5679282cca5c2eebca0b7
3
+ metadata.gz: 0547b3cc3e8f1c34bbcb472bde62fcb97a24a8f9d7923021e3d7c1acea6072b8
4
+ data.tar.gz: 077211f324433c5e720d1bb57d5a9836805e349baaa0572278e43709fc345722
5
5
  SHA512:
6
- metadata.gz: fa2498cb4179a3a96b0e3386da2d0fa2f37688e9fb0577f68b0465d1041fb407df3da9102c8901bbc4bbd7b790f9ab31456b4f05ba26a296d4132823d89be698
7
- data.tar.gz: 2241427a731a6a45ce215e7547e0a5e6133ce382794622377dfa24a821cd4b95d1fea6ddea0d3a4187fae7a1309963c44a5303ee0c890c9680aa8b3f4fdbcc71
6
+ metadata.gz: 11c4a47b9faa967b2b6e9c0c393a9f43220e3c1bf01a949951087355ad45d770bcc15f7af8700ee8c5a24ca244b6b150738ac8b752933b3b6e8016c53e6bd222
7
+ data.tar.gz: 269d0e18280295248204b860366f8d8213a5b549a09e5c39a224ddd54c4123715d1adada1b84ddbad56e694bc07c84a196b50232738e3123908e4f41684f7552
@@ -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
@@ -22,20 +22,21 @@ module GitFit
22
22
  (builtin + configured).uniq
23
23
  end
24
24
 
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
- rescue StandardError => e
37
- say_status :error, e.message, :red
38
- end
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) }
@@ -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
@@ -18,6 +18,10 @@ module GitFit
18
18
  @db
19
19
  end
20
20
 
21
+ def checkpoint
22
+ @db.fetch('PRAGMA wal_checkpoint(TRUNCATE)').first
23
+ end
24
+
21
25
  def migrate!
22
26
  dedup_schema_migrations
23
27
  run_migrations
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitFit
4
- VERSION = '0.8.7'
4
+ VERSION = '0.8.8'
5
5
  end
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.8.7
4
+ version: 0.8.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lax