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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2995ed8296855e2b64a848d1c6be572f21b4c77d
4
- data.tar.gz: bb267b3e7f42148109699f6a17ab9eb11e611823
3
+ metadata.gz: 733121449aea416c67e1d0e5ab5d22c131465637
4
+ data.tar.gz: a9f0223530f33b7c4e978105de1287f9c8603250
5
5
  SHA512:
6
- metadata.gz: ab06de5813d616854b69fedc6ffc98c0b138903fb6dfa0b9570ef98c914d2470eb40cc26973e91a56a9ea152f99ab1e532d0adfc8674802c18b1a78b022082a8
7
- data.tar.gz: c13f6d63f49e2b393cfa82ed0e08c1772dfc792042cfbf9cab8350dec2f9fc13c330b4710944dc20b3d47a988d57f2d4d03be2e5b2130d3a1b6f81f1c112fd78
6
+ metadata.gz: ed64f68737ca9ca07819d6848ab8bd056ee79add352fbbf3915f5e74e21607f24f5be99535109542275b542e2388d039968a4ad3bbd8f516676f551e8c4a43eb
7
+ data.tar.gz: cbd911866995b70530d3d39bc43bb150fd95441798e0bc5c24edcdc46787f4dc754edd8d7335ff399c9991b4e5e08a1aa1ad40157793faa8e1a3adb276e1e39f
@@ -1,2 +1,2 @@
1
1
  gem build log_magic.gemspec
2
- gem install log_magic-0.0.3.gem
2
+ gem install log_magic-0.0.4.gem
@@ -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'
@@ -1,5 +1,8 @@
1
1
  - explainer_sections.each do |explainer_section|
2
2
  = explainer_section.explanation
3
3
 
4
+ = settings_explainer_section.explanation
5
+
6
+ %h2 Query
4
7
  %p
5
8
  = pretty_print_json(query_json)
@@ -0,0 +1,3 @@
1
+ %h2 Settings
2
+
3
+ = pretty_print_json(index_settings)
@@ -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
- attr_accessor :db
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 = ::SecureRandom.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.get(uuid)
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
- uuid = persist(persistance_layer, query_json)
15
- output(query_json, uuid)
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 persist(persistance_layer, query_json)
28
- persistance_layer.add_value(query_json)
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.3
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