sql-jarvis 1.9.9 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -2
- data/app/controllers/blazer/queries_controller.rb +7 -1
- data/app/views/blazer/queries/show.html.erb +4 -3
- data/blazer.gemspec +3 -0
- data/lib/blazer.rb +6 -0
- data/lib/blazer/excel_parser.rb +40 -0
- data/lib/blazer/version.rb +1 -1
- metadata +46 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a692d1fe0f09c3fe9865e2a2c4b3f1835899672aa6accbbf150b90e43fbbdc5b
|
4
|
+
data.tar.gz: fb1c04bed559e70e7afa3207769a60700e91aa6400b68eadd0d5a4774b1c0c5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e17d107a062ccf874485e39ec1893f15a2c7986c1f6667f360a75cc04a7f7b5b6154704dc5f1a20a481a566410f009db9aa445448541fdb0194321b1f0381de8
|
7
|
+
data.tar.gz: 2dd68c65560fa2e01e3b402df83bf1b2b1929163d4b01e323e3499664b077f6fb8edbe743d42dfc32981abf795586952a8a28fd1cab3fc4f03c442b04904659d
|
data/Gemfile
CHANGED
@@ -262,12 +262,18 @@ module Blazer
|
|
262
262
|
end
|
263
263
|
end
|
264
264
|
|
265
|
+
filename = @query.try(:name).try(:parameterize).presence || 'query'
|
265
266
|
respond_to do |format|
|
266
267
|
format.html do
|
267
268
|
render layout: false
|
268
269
|
end
|
270
|
+
format.xlsx do
|
271
|
+
parser = ::Blazer::ExcelParser.new(@query, @columns, @rows)
|
272
|
+
tmp_file = parser.export
|
273
|
+
send_file tmp_file, type: "application/xlsx; charset=utf-8; header=present", disposition: "attachment; filename=\"#{parser.filename}\""
|
274
|
+
end
|
269
275
|
format.csv do
|
270
|
-
send_data csv_data(@columns, @rows, @data_source), type: "text/csv; charset=utf-8; header=present", disposition: "attachment; filename=\"#{
|
276
|
+
send_data csv_data(@columns, @rows, @data_source), type: "text/csv; charset=utf-8; header=present", disposition: "attachment; filename=\"#{filename}.csv\""
|
271
277
|
end
|
272
278
|
end
|
273
279
|
end
|
@@ -3,18 +3,19 @@
|
|
3
3
|
<div class="topbar">
|
4
4
|
<div class="container">
|
5
5
|
<div class="row" style="padding-top: 13px;">
|
6
|
-
<div class="col-sm-
|
6
|
+
<div class="col-sm-8">
|
7
7
|
<%= render partial: "blazer/nav" %>
|
8
8
|
<h3 style="margin: 0; line-height: 34px; display: inline;">
|
9
9
|
<%= @query.name %>
|
10
10
|
</h3>
|
11
11
|
</div>
|
12
|
-
<div class="col-sm-
|
12
|
+
<div class="col-sm-4 text-right">
|
13
13
|
<%= link_to "Edit", edit_query_path(@query, variable_params), class: "btn btn-default", disabled: !@query.editable?(blazer_user) %>
|
14
14
|
<%= link_to "Fork", new_query_path(variable_params.merge(fork_query_id: @query.id, data_source: @query.data_source, name: @query.name)), class: "btn btn-info" %>
|
15
15
|
|
16
16
|
<% if !@error && @success %>
|
17
|
-
<%= button_to "
|
17
|
+
<%= button_to "⤓ .csv", run_queries_path(query_id: @query.id, format: "csv"), params: {statement: @statement}, class: "btn btn-primary" %>
|
18
|
+
<%= button_to "⤓ .xlsx", run_queries_path(query_id: @query.id, format: "xlsx"), params: {statement: @statement}, class: "btn btn-primary" %>
|
18
19
|
<% end %>
|
19
20
|
</div>
|
20
21
|
</div>
|
data/blazer.gemspec
CHANGED
@@ -17,6 +17,9 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
+
spec.add_dependency "zip-zip"
|
21
|
+
spec.add_dependency "axlsx"
|
22
|
+
spec.add_dependency "axlsx_rails"
|
20
23
|
spec.add_dependency "railties", ">= 4"
|
21
24
|
spec.add_dependency "activerecord", ">= 4"
|
22
25
|
spec.add_dependency "chartkick"
|
data/lib/blazer.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
require "csv"
|
2
2
|
require "yaml"
|
3
3
|
require "chartkick"
|
4
|
+
require "zip/zip"
|
5
|
+
require "axlsx"
|
4
6
|
require "safely/core"
|
5
7
|
require "blazer/version"
|
6
8
|
require "blazer/data_source"
|
7
9
|
require "blazer/result"
|
10
|
+
require "blazer/excel_parser"
|
8
11
|
require "blazer/run_statement"
|
9
12
|
require "blazer/adapters/base_adapter"
|
10
13
|
require "blazer/adapters/athena_adapter"
|
@@ -215,3 +218,6 @@ Blazer.register_adapter "presto", Blazer::Adapters::PrestoAdapter
|
|
215
218
|
Blazer.register_adapter "mongodb", Blazer::Adapters::MongodbAdapter
|
216
219
|
Blazer.register_adapter "sql", Blazer::Adapters::SqlAdapter
|
217
220
|
Blazer.register_adapter "snowflake", Blazer::Adapters::SnowflakeAdapter
|
221
|
+
|
222
|
+
Mime::Type.register "application/xlsx", :xlsx
|
223
|
+
Mime::Type.register "application/xls", :xlsx
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Blazer
|
2
|
+
class ExcelParser
|
3
|
+
|
4
|
+
def initialize(query, columns, rows)
|
5
|
+
@query = query
|
6
|
+
@columns = columns
|
7
|
+
@rows = rows
|
8
|
+
@excel = ::Axlsx::Package.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def export
|
12
|
+
load_data!
|
13
|
+
save_file!
|
14
|
+
end
|
15
|
+
|
16
|
+
def filename
|
17
|
+
"#{query.name.to_s.parameterize}-#{Time.current.strftime('%y-%m-%d')}.xlsx"
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
attr_reader :query, :excel
|
23
|
+
|
24
|
+
def load_data!
|
25
|
+
excel.workbook.add_worksheet(name: "ID #{query.id}") do |sheet|
|
26
|
+
sheet.add_row @columns
|
27
|
+
@rows.each do |row|
|
28
|
+
sheet.add_row row
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def save_file!
|
34
|
+
tmp_file = "tmp/#{filename}"
|
35
|
+
excel.serialize(tmp_file)
|
36
|
+
return tmp_file
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
data/lib/blazer/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sql-jarvis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ThanhKhoaIT
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: zip-zip
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: axlsx
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: axlsx_rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
13
55
|
- !ruby/object:Gem::Dependency
|
14
56
|
name: railties
|
15
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -197,6 +239,7 @@ files:
|
|
197
239
|
- lib/blazer/data_source.rb
|
198
240
|
- lib/blazer/detect_anomalies.R
|
199
241
|
- lib/blazer/engine.rb
|
242
|
+
- lib/blazer/excel_parser.rb
|
200
243
|
- lib/blazer/result.rb
|
201
244
|
- lib/blazer/run_statement.rb
|
202
245
|
- lib/blazer/run_statement_job.rb
|
@@ -225,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
268
|
version: '0'
|
226
269
|
requirements: []
|
227
270
|
rubyforge_project:
|
228
|
-
rubygems_version: 2.7.
|
271
|
+
rubygems_version: 2.7.8
|
229
272
|
signing_key:
|
230
273
|
specification_version: 4
|
231
274
|
summary: Fork from ankane! Explore your data with SQL. Easily create charts and dashboards,
|