dbhero 1.1.9 → 1.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/dbhero/dataclip.rb +14 -2
- data/app/models/dbhero/dataclip_read.rb +6 -0
- data/app/views/dbhero/dataclips/_form.html.slim +3 -3
- data/lib/dbhero/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 704f1ecef47798c3d2f6e0f1bedf4fc33f836c0a
|
4
|
+
data.tar.gz: f2ba345d1695e024d9b7347a1d9ba2828cf22687
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b93cfb176d3c44c692cf5131af3cf3b0dfebb1530da36695bb9ca8b3b7b64792e6832a6fb597674fa007b1a2e7ee8b11d66bee6b6163c208dd1a8c19a0447c7e
|
7
|
+
data.tar.gz: c0b0217ae72a12906543ee967435ec770fa60fcd0f7fab585e3347fe063e08601104615713d21164356c8436befde8c3f2cebabfc9124104e9c9d97c329e7af4
|
@@ -3,6 +3,7 @@ require 'csv'
|
|
3
3
|
module Dbhero
|
4
4
|
class Dataclip < ActiveRecord::Base
|
5
5
|
before_create :set_token
|
6
|
+
after_save :refresh_cache
|
6
7
|
|
7
8
|
scope :ordered, -> { order(updated_at: :desc) }
|
8
9
|
scope :search, ->(term) { where(arel_table[:description].matches("%#{term}%")) }
|
@@ -10,6 +11,11 @@ module Dbhero
|
|
10
11
|
validates :description, :raw_query, presence: true
|
11
12
|
attr_reader :q_result
|
12
13
|
|
14
|
+
def refresh_cache
|
15
|
+
Rails.cache.delete("dataclip_#{self.token}")
|
16
|
+
end
|
17
|
+
|
18
|
+
|
13
19
|
def set_token
|
14
20
|
self.token = SecureRandom.uuid unless self.token
|
15
21
|
end
|
@@ -30,10 +36,16 @@ module Dbhero
|
|
30
36
|
@total_rows ||= @q_result.rows.length
|
31
37
|
end
|
32
38
|
|
39
|
+
def cached?
|
40
|
+
@cached ||= Rails.cache.fetch("dataclip_#{self.token}").present?
|
41
|
+
end
|
42
|
+
|
33
43
|
def query_result
|
34
|
-
|
44
|
+
DataclipRead.transaction do
|
35
45
|
begin
|
36
|
-
@q_result ||=
|
46
|
+
@q_result ||= Rails.cache.fetch("dataclip_#{self.token}") do
|
47
|
+
DataclipRead.connection.select_all(self.raw_query)
|
48
|
+
end
|
37
49
|
rescue => e
|
38
50
|
self.errors.add(:base, e.message)
|
39
51
|
end
|
@@ -17,7 +17,7 @@
|
|
17
17
|
.input-field
|
18
18
|
= f.text_area :raw_query, class: 'editor-style z-depth-1'
|
19
19
|
.row
|
20
|
-
.col.
|
20
|
+
.col.s9
|
21
21
|
.input-field
|
22
22
|
.switch
|
23
23
|
label
|
@@ -25,8 +25,8 @@
|
|
25
25
|
= f.check_box :private
|
26
26
|
span.lever style='float: left;'
|
27
27
|
i style="margin-top: -20px; float: left" class="small mdi-action-lock-outline tooltipped" data-position="right" data-delay="50" data-tooltip="Only users that same role as you can see the clip"
|
28
|
-
.col.
|
28
|
+
.col.s3.right-align
|
29
29
|
.input-field
|
30
30
|
button class="btn waves-effect waves-light blue darken-3" type="submit" name="action"
|
31
|
-
| Save
|
31
|
+
| Save & Refresh
|
32
32
|
i class="mdi-action-done-all left"
|
data/lib/dbhero/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbhero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antônio Roberto Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -181,6 +181,7 @@ files:
|
|
181
181
|
- app/helpers/dbhero/application_helper.rb
|
182
182
|
- app/helpers/dbhero/dataclips_helper.rb
|
183
183
|
- app/models/dbhero/dataclip.rb
|
184
|
+
- app/models/dbhero/dataclip_read.rb
|
184
185
|
- app/views/dbhero/dataclips/_clip_table.html.slim
|
185
186
|
- app/views/dbhero/dataclips/_form.html.slim
|
186
187
|
- app/views/dbhero/dataclips/edit.html.slim
|