log_magic 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rebuild +1 -1
- data/lib/log_magic.rb +1 -0
- data/lib/log_magic/explainer_templates/searchkick.haml +3 -0
- data/lib/log_magic/explainer_templates/settings.haml +3 -0
- data/lib/log_magic/explainers/explainer_sections/settings_explainer.rb +21 -0
- data/lib/log_magic/explainers/searchkick_explainer.rb +10 -4
- data/lib/log_magic/persistance_layer.rb +7 -9
- data/lib/log_magic/refiners/searchkick_refiner.rb +16 -4
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 733121449aea416c67e1d0e5ab5d22c131465637
|
4
|
+
data.tar.gz: a9f0223530f33b7c4e978105de1287f9c8603250
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed64f68737ca9ca07819d6848ab8bd056ee79add352fbbf3915f5e74e21607f24f5be99535109542275b542e2388d039968a4ad3bbd8f516676f551e8c4a43eb
|
7
|
+
data.tar.gz: cbd911866995b70530d3d39bc43bb150fd95441798e0bc5c24edcdc46787f4dc754edd8d7335ff399c9991b4e5e08a1aa1ad40157793faa8e1a3adb276e1e39f
|
data/bin/rebuild
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
gem build log_magic.gemspec
|
2
|
-
gem install log_magic-0.0.
|
2
|
+
gem install log_magic-0.0.4.gem
|
data/lib/log_magic.rb
CHANGED
@@ -56,4 +56,5 @@ require 'log_magic/explainers/searchkick_explainer'
|
|
56
56
|
require 'log_magic/explainers/explainer_sections/dis_max_explainer'
|
57
57
|
require 'log_magic/explainers/explainer_sections/match_explainer'
|
58
58
|
require 'log_magic/explainers/explainer_sections/boost_explainer'
|
59
|
+
require 'log_magic/explainers/explainer_sections/settings_explainer'
|
59
60
|
require 'log_magic/persistance_layer'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class LogMagic::SearchkickExplainer::SettingsExplainerSection
|
2
|
+
include ::LogMagic::TemplatingUtils
|
3
|
+
include ::LogMagic::JSONUtils
|
4
|
+
attr_reader :elasticsearch_url
|
5
|
+
|
6
|
+
def initialize(elasticsearch_url)
|
7
|
+
@elasticsearch_url = elasticsearch_url
|
8
|
+
end
|
9
|
+
|
10
|
+
def index_settings
|
11
|
+
`curl #{elasticsearch_url}/_settings`
|
12
|
+
end
|
13
|
+
|
14
|
+
def explanation
|
15
|
+
rendered_template
|
16
|
+
end
|
17
|
+
|
18
|
+
def template_name
|
19
|
+
'settings.haml'
|
20
|
+
end
|
21
|
+
end
|
@@ -5,15 +5,21 @@ require 'haml'
|
|
5
5
|
class LogMagic::SearchkickExplainer
|
6
6
|
include ::LogMagic::JSONUtils
|
7
7
|
include ::LogMagic::TemplatingUtils
|
8
|
-
|
9
|
-
attr_accessor :database_name
|
10
|
-
|
8
|
+
|
11
9
|
def initialize()
|
12
10
|
@persistance_layer = ::LogMagic::PersistanceLayer.new
|
13
11
|
end
|
14
12
|
|
15
13
|
def query_json
|
16
|
-
@persistance_layer.retrieve_value(@uuid)
|
14
|
+
@persistance_layer.retrieve_value(@uuid, 'query_json')
|
15
|
+
end
|
16
|
+
|
17
|
+
def elasticsearch_url
|
18
|
+
@persistance_layer.retrieve_value(@uuid, 'elasticsearch_url')
|
19
|
+
end
|
20
|
+
|
21
|
+
def settings_explainer_section
|
22
|
+
SettingsExplainerSection.new(elasticsearch_url)
|
17
23
|
end
|
18
24
|
|
19
25
|
def explainer_section_classes
|
@@ -1,21 +1,19 @@
|
|
1
1
|
require 'redis'
|
2
|
+
require 'securerandom'
|
2
3
|
|
3
4
|
class LogMagic::PersistanceLayer
|
4
|
-
|
5
|
+
attr_reader :uuid
|
5
6
|
|
6
7
|
def initialize
|
7
8
|
@redis = Redis.new
|
9
|
+
@uuid = ::SecureRandom.uuid
|
8
10
|
end
|
9
11
|
|
10
|
-
def add_value(value)
|
11
|
-
uuid
|
12
|
-
|
13
|
-
@redis.set(uuid, value)
|
14
|
-
|
15
|
-
return uuid
|
12
|
+
def add_value(key, value)
|
13
|
+
@redis.hset(@uuid, key, value)
|
16
14
|
end
|
17
15
|
|
18
|
-
def retrieve_value(uuid)
|
19
|
-
@redis.
|
16
|
+
def retrieve_value(uuid, key)
|
17
|
+
@redis.hget(uuid, key)
|
20
18
|
end
|
21
19
|
end
|
@@ -10,9 +10,13 @@ class LogMagic::SearchkickRefiner
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def compute(persistance_layer)
|
13
|
+
elasticsearch_url = extract_elasticsearch_url
|
14
|
+
persist_elasticsearch_url(persistance_layer, elasticsearch_url)
|
15
|
+
|
13
16
|
query_json = extract_query_json
|
14
|
-
|
15
|
-
|
17
|
+
persist_query_json(persistance_layer, query_json)
|
18
|
+
|
19
|
+
output(query_json, persistance_layer.uuid)
|
16
20
|
end
|
17
21
|
|
18
22
|
def output(query_json, uuid)
|
@@ -24,7 +28,15 @@ class LogMagic::SearchkickRefiner
|
|
24
28
|
@lines.last.match(/'.*'/)[0][1..-2]
|
25
29
|
end
|
26
30
|
|
27
|
-
def
|
28
|
-
|
31
|
+
def extract_elasticsearch_url
|
32
|
+
@lines.last.match(/https?:\/\/[^\/]*\/[^\/]*/)[0]
|
33
|
+
end
|
34
|
+
|
35
|
+
def persist_query_json(persistance_layer, query_json)
|
36
|
+
persistance_layer.add_value('query_json', query_json)
|
37
|
+
end
|
38
|
+
|
39
|
+
def persist_elasticsearch_url(persistance_layer, elasticsearch_url)
|
40
|
+
persistance_layer.add_value('elasticsearch_url', elasticsearch_url)
|
29
41
|
end
|
30
42
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: log_magic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manuel Korfmann
|
@@ -109,9 +109,11 @@ files:
|
|
109
109
|
- lib/log_magic/explainer_templates/dis_max.haml
|
110
110
|
- lib/log_magic/explainer_templates/match.haml
|
111
111
|
- lib/log_magic/explainer_templates/searchkick.haml
|
112
|
+
- lib/log_magic/explainer_templates/settings.haml
|
112
113
|
- lib/log_magic/explainers/explainer_sections/boost_explainer.rb
|
113
114
|
- lib/log_magic/explainers/explainer_sections/dis_max_explainer.rb
|
114
115
|
- lib/log_magic/explainers/explainer_sections/match_explainer.rb
|
116
|
+
- lib/log_magic/explainers/explainer_sections/settings_explainer.rb
|
115
117
|
- lib/log_magic/explainers/searchkick_explainer.rb
|
116
118
|
- lib/log_magic/log_listener.rb
|
117
119
|
- lib/log_magic/persistance_layer.rb
|