sqlui 0.1.76 → 0.1.77
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/.release-version +1 -1
- data/app/github/tree_client.rb +4 -8
- data/app/server.rb +42 -7
- data/app/sqlui.rb +1 -29
- data/client/resources/sqlui.js +1152 -741
- metadata +2 -114
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 813ba5e47c2d4409ff6601fd9974f649f4099da7bc61dc82d2f619313c033cbe
|
4
|
+
data.tar.gz: 57e1ebab4287fd3b49f2d6e1cc37009cabc60aba6d3fb6c7b2fed5f3cc107d5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48a36192980463f3a2ce4ef80b3b74011ee8e42b8d6dd215b8ac8f01f5146682ceca736888c661789c024b57a33bf7e7b771ea10c1f5b33f2d91891689eae5ef
|
7
|
+
data.tar.gz: 21ea275d80725c1907ed6d04e3c5d3c83bd84a18fbbfdf56d490f60959b3fb515c84bb219020afc3fd4769add109031c6bba9a6cbd89698116a8cb1ca715019d
|
data/.release-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.77
|
data/app/github/tree_client.rb
CHANGED
@@ -25,10 +25,7 @@ module Github
|
|
25
25
|
end
|
26
26
|
|
27
27
|
DEFAULT_MAX_TREE_CACHE_AGE_SECONDS = 60 * 5 # 5 minutes
|
28
|
-
DEFAULT_MAX_FILE_CACHE_AGE_SECONDS = 60 * 60 * 24 *
|
29
|
-
|
30
|
-
MAX_TREE_SIZE = 100
|
31
|
-
private_constant :MAX_TREE_SIZE
|
28
|
+
DEFAULT_MAX_FILE_CACHE_AGE_SECONDS = 60 * 60 * 24 * 365 # 1 year
|
32
29
|
|
33
30
|
def initialize(access_token:, cache:, logger: Logger.new($stdout))
|
34
31
|
check_non_empty_string(access_token: access_token)
|
@@ -52,9 +49,8 @@ module Github
|
|
52
49
|
end
|
53
50
|
|
54
51
|
response['tree'] = response['tree'].select { |blob| regex.match?(blob['path']) }
|
55
|
-
|
56
|
-
|
57
|
-
latch = CountDownLatch.new(response['tree'].size)
|
52
|
+
tree_size = response['tree'].size
|
53
|
+
latch = CountDownLatch.new(tree_size)
|
58
54
|
response['tree'].each do |blob|
|
59
55
|
TreeClient.thread_pool.post do
|
60
56
|
blob['content'] =
|
@@ -64,7 +60,7 @@ module Github
|
|
64
60
|
end
|
65
61
|
end
|
66
62
|
|
67
|
-
latch.await(timeout:
|
63
|
+
latch.await(timeout: [10, tree_size / 2].max)
|
68
64
|
raise 'failed to load saved files' unless response['tree'].all? { |blob| blob['content'] }
|
69
65
|
|
70
66
|
Tree.for(owner: owner, repo: repo, ref: ref, tree_response: response)
|
data/app/server.rb
CHANGED
@@ -36,7 +36,7 @@ class Server < Sinatra::Base
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
def self.init_and_run(config, resources_dir
|
39
|
+
def self.init_and_run(config, resources_dir)
|
40
40
|
Sqlui.logger.info("Starting SQLUI v#{Version::SQLUI}")
|
41
41
|
Sqlui.logger.info("Airbrake enabled: #{config.airbrake[:server]&.[](:enabled) || false}")
|
42
42
|
|
@@ -113,7 +113,23 @@ class Server < Sinatra::Base
|
|
113
113
|
erb :databases, locals: { config: config, resource_path_map: resource_path_map }
|
114
114
|
end
|
115
115
|
|
116
|
+
github_cache = create_github_cache
|
116
117
|
config.database_configs.each do |database|
|
118
|
+
# Prefetch all trees on startup. This should happen before the health endpoint is available.
|
119
|
+
if (saved_config = database.saved_config)
|
120
|
+
tree_client = Github::TreeClient.new(
|
121
|
+
access_token: database.saved_config.token,
|
122
|
+
cache: github_cache,
|
123
|
+
logger: Sqlui.logger
|
124
|
+
)
|
125
|
+
tree_client.get_tree(
|
126
|
+
owner: saved_config.owner,
|
127
|
+
repo: saved_config.repo,
|
128
|
+
ref: saved_config.branch,
|
129
|
+
regex: saved_config.regex
|
130
|
+
)
|
131
|
+
end
|
132
|
+
|
117
133
|
get "#{config.base_url_path}/#{database.url_path}/?" do
|
118
134
|
redirect "#{database.url_path}/query", 301
|
119
135
|
end
|
@@ -121,11 +137,6 @@ class Server < Sinatra::Base
|
|
121
137
|
post "#{config.base_url_path}/#{database.url_path}/metadata" do
|
122
138
|
tree = nil
|
123
139
|
if (saved_config = database.saved_config)
|
124
|
-
tree_client = Github::TreeClient.new(
|
125
|
-
access_token: database.saved_config.token,
|
126
|
-
cache: github_cache,
|
127
|
-
logger: Sqlui.logger
|
128
|
-
)
|
129
140
|
tree = tree_client.get_tree(
|
130
141
|
owner: saved_config.owner,
|
131
142
|
repo: saved_config.repo,
|
@@ -361,7 +372,31 @@ class Server < Sinatra::Base
|
|
361
372
|
run!
|
362
373
|
end
|
363
374
|
|
364
|
-
|
375
|
+
def self.create_github_cache
|
376
|
+
return Github::Cache.new({}, logger: Sqlui.logger) unless ENV['USE_LOCAL_SAVED_FILES']
|
377
|
+
|
378
|
+
paths = Dir.glob('sql/**/*.sql')
|
379
|
+
blobs = paths.map { |path| { 'path' => path, 'sha' => 'foo' } }
|
380
|
+
github_cache_hash = {
|
381
|
+
'https://api.github.com/repos/nicholasdower/sqlui/git/trees/master?recursive=true' =>
|
382
|
+
Github::Cache::Entry.new(
|
383
|
+
{
|
384
|
+
'sha' => 'foo',
|
385
|
+
'truncated' => false,
|
386
|
+
'tree' => blobs
|
387
|
+
}, 60 * 60 * 24 * 365
|
388
|
+
)
|
389
|
+
}
|
390
|
+
paths.each do |path|
|
391
|
+
github_cache_hash["https://api.github.com/repos/nicholasdower/sqlui/contents/#{path}?ref=foo"] =
|
392
|
+
Github::Cache::Entry.new(
|
393
|
+
{
|
394
|
+
'content' => Base64.encode64(File.read(path))
|
395
|
+
}, 60 * 60 * 24 * 365
|
396
|
+
)
|
397
|
+
end
|
398
|
+
Github::Cache.new(github_cache_hash, logger: Sqlui.logger)
|
399
|
+
end
|
365
400
|
|
366
401
|
def find_selected_queries(full_sql, selection)
|
367
402
|
if selection
|
data/app/sqlui.rb
CHANGED
@@ -28,7 +28,7 @@ class Sqlui
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def run
|
31
|
-
Server.init_and_run(@config, @resources_dir
|
31
|
+
Server.init_and_run(@config, @resources_dir)
|
32
32
|
end
|
33
33
|
|
34
34
|
def self.from_command_line(args)
|
@@ -42,32 +42,4 @@ class Sqlui
|
|
42
42
|
|
43
43
|
Sqlui.new(args[0])
|
44
44
|
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
def github_cache
|
49
|
-
return Github::Cache.new({}, logger: Sqlui.logger) unless ENV['USE_LOCAL_SAVED_FILES']
|
50
|
-
|
51
|
-
paths = Dir.glob('sql/friends/*.sql')
|
52
|
-
blobs = paths.map { |path| { 'path' => path, 'sha' => 'foo' } }
|
53
|
-
github_cache_hash = {
|
54
|
-
'https://api.github.com/repos/nicholasdower/sqlui/git/trees/master?recursive=true' =>
|
55
|
-
Github::Cache::Entry.new(
|
56
|
-
{
|
57
|
-
'sha' => 'foo',
|
58
|
-
'truncated' => false,
|
59
|
-
'tree' => blobs
|
60
|
-
}, 60 * 60 * 24 * 365
|
61
|
-
)
|
62
|
-
}
|
63
|
-
paths.each do |path|
|
64
|
-
github_cache_hash["https://api.github.com/repos/nicholasdower/sqlui/contents/#{path}?ref=foo"] =
|
65
|
-
Github::Cache::Entry.new(
|
66
|
-
{
|
67
|
-
'content' => Base64.encode64(File.read(path))
|
68
|
-
}, 60 * 60 * 24 * 365
|
69
|
-
)
|
70
|
-
end
|
71
|
-
Github::Cache.new(github_cache_hash, logger: Sqlui.logger)
|
72
|
-
end
|
73
45
|
end
|