picky-statistics 4.5.1 → 4.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,7 +21,7 @@ Stats = LogfileReader.new log_file
21
21
  class PickyStatistics < Sinatra::Base
22
22
 
23
23
  set :static, true
24
- set :public, File.expand_path('.', Dir.pwd)
24
+ set :public_folder, File.expand_path('.', Dir.pwd)
25
25
  set :views, File.expand_path('views', Dir.pwd)
26
26
  set :haml, { :format => :html5 }
27
27
 
@@ -51,7 +51,6 @@ var allocationsScale = d3.scale.linear()
51
51
  .domain([0, 0])
52
52
  .rangeRound(chartWidth);
53
53
 
54
-
55
54
  var offsetScale = d3.scale.linear()
56
55
  .domain([0, 0])
57
56
  .rangeRound(chartWidth);
@@ -125,10 +124,10 @@ function renderAll() {
125
124
 
126
125
  // Render the total.
127
126
  //
128
- d3.selectAll("#total")
127
+ d3.selectAll("aside.totals .total")
129
128
  .text(formatNumber(search.size()));
130
129
 
131
- d3.select("#active").text(formatNumber(all.value()));
130
+ d3.selectAll("aside.totals .active").text(formatNumber(all.value()));
132
131
  }
133
132
 
134
133
  // Like d3.time.format, but faster.
@@ -156,12 +155,13 @@ window.reset = function(i) {
156
155
 
157
156
  var intervalUpdating = false;
158
157
 
159
- function updateStatistics(reloadAll) {
158
+ function updateStatistics(reloadAll, seconds) {
160
159
  path = reloadAll ? 'index.json' : 'since_last.json';
161
160
 
162
- showNotice();
161
+ if (!seconds || seconds >= 30) { showNotice(); }
162
+
163
163
  d3.json(path, function(searches) {
164
- if (searches.length == 0) { return; }
164
+ if (!searches || searches.length == 0) { return; }
165
165
 
166
166
  var totalMin = 1000000; // Highest minimum set to sane number.
167
167
  var totalMax = 0;
@@ -193,24 +193,23 @@ function updateStatistics(reloadAll) {
193
193
  if (durationMax < d.duration) { durationMax = d.duration; }
194
194
  });
195
195
 
196
- // console.log([totalMin, totalMax]);
197
-
198
196
  // Set scales.
199
197
  //
200
198
  var totalDomain = totalScale.domain();
201
- totalScale.domain([d3.min([totalMin, totalDomain[0]])*0.9, d3.max([totalMax, totalDomain[1]])*1.1]);
199
+ totalScale.domain([d3.min([totalMin, totalDomain[0]])*0.9, d3.max([totalMax, totalDomain[1]])]);
202
200
  var allocationsDomain = allocationsScale.domain();
203
- allocationsScale.domain([d3.min([allocationsMin, allocationsDomain[0]])*0.9, d3.max([allocationsMax, allocationsDomain[1]])*1.1]);
201
+ allocationsScale.domain([d3.min([allocationsMin, allocationsDomain[0]])*0.9, d3.max([allocationsMax, allocationsDomain[1]])]);
204
202
  var offsetDomain = offsetScale.domain();
205
- offsetScale.domain([d3.min([offsetMin, offsetDomain[0]])*0.9, d3.max([offsetMax, offsetDomain[1]])*1.1]);
203
+ offsetScale.domain([d3.min([offsetMin, offsetDomain[0]])*0.9, d3.max([offsetMax, offsetDomain[1]])]);
206
204
  var durationDomain = durationScale.domain();
207
- durationScale.domain([d3.min([durationMin, durationDomain[0]])*0.9, d3.max([durationMax, durationDomain[1]])*1.1]);
205
+ durationScale.domain([d3.min([durationMin, durationDomain[0]])*0.9, d3.max([durationMax, durationDomain[1]])]);
208
206
 
209
207
  search.add(searches);
210
208
 
211
209
  renderAll();
210
+
211
+ if (!seconds || seconds >= 30) { hideNotice(); }
212
212
  });
213
- hideNotice();
214
213
  };
215
214
 
216
215
  var periodicalUpdaterId;
@@ -218,7 +217,7 @@ var periodicalUpdaterId;
218
217
  function updateStatisticsPeriodically(seconds) {
219
218
  clearInterval(periodicalUpdaterId);
220
219
  periodicalUpdaterId = setInterval(function() {
221
- updateStatistics();
220
+ updateStatistics(false, seconds);
222
221
  }, 1000*seconds);
223
222
  intervalUpdating = true;
224
223
  };
@@ -48,9 +48,6 @@ input {
48
48
  height: 4em;
49
49
  margin: -2em 0px 0px -5em;
50
50
  }
51
- #notice.show {
52
- display: block;
53
- }
54
51
 
55
52
  .actions {
56
53
  padding: 5px;
@@ -171,6 +168,6 @@ span#active, span#total {
171
168
  color: green;
172
169
  }
173
170
 
174
- aside {
171
+ aside.totals {
175
172
  float: right;
176
173
  }
@@ -8,6 +8,13 @@
8
8
  %script{ :src => 'javascripts/statistics.js', :type => 'text/javascript' }
9
9
 
10
10
  %body{ :onload => "document.getElementsByTagName('input')[0].click(); updateStatistics(true);" }
11
+ %aside.totals
12
+ %span.active
13
+ -
14
+ of
15
+ %span.total
16
+ -
17
+ searches selected.
11
18
  %h1 Clam: Picky Statistics Interface.
12
19
  .actions
13
20
  %button{ :href => '#', :onclick => 'javascript:updateStatistics();' } Update now
@@ -15,6 +22,8 @@
15
22
  |
16
23
  %input{ :id => 'updateStop', :type => "radio", :name => "updating", :onclick => 'javascript:stopUpdatingStatistics();' }
17
24
  %label{ :for => 'updateStop' } Don't update
25
+ %input{ :id => 'update1', :type => "radio", :name => "updating", :onclick => 'javascript:updateStatisticsPeriodically(1);' }
26
+ %label{ :for => 'update1' } Every second
18
27
  %input{ :id => 'update3', :type => "radio", :name => "updating", :onclick => 'javascript:updateStatisticsPeriodically(3);' }
19
28
  %label{ :for => 'update3' } Every 3 seconds
20
29
  %input{ :id => 'update10', :type => "radio", :name => "updating", :onclick => 'javascript:updateStatisticsPeriodically(10);' }
@@ -39,11 +48,11 @@
39
48
  #duration-chart.chart
40
49
  %h2.title Duration
41
50
 
42
- %aside#totals
43
- %span#active
51
+ %aside.totals
52
+ %span.active
44
53
  -
45
54
  of
46
- %span#total
55
+ %span.total
47
56
  -
48
57
  searches selected.
49
58
 
@@ -28,8 +28,8 @@ class LogfileReader
28
28
  @last_offset = 0
29
29
  end
30
30
 
31
- def since log_offset = 0
32
- @last_offset ||= 0
31
+ def since log_offset = nil
32
+ @last_offset = log_offset || 0
33
33
 
34
34
  start_time = Time.now
35
35
 
@@ -42,7 +42,7 @@ class LogfileReader
42
42
  File.open(statistics, 'r') do |file|
43
43
  while line = file.gets
44
44
  next if line =~ /\A\s*\#/
45
- results << process(line)
45
+ results << process(line) rescue nil
46
46
  end
47
47
  end
48
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picky-statistics
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.1
4
+ version: 4.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-07-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
16
- requirement: &70282333548640 !ruby/object:Gem::Requirement
16
+ requirement: &70341398424060 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70282333548640
24
+ version_requirements: *70341398424060
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70282333547780 !ruby/object:Gem::Requirement
27
+ requirement: &70341398437100 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: 1.3.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70282333547780
35
+ version_requirements: *70341398437100
36
36
  description: Statistics interface for Picky, the fast Ruby search engine.
37
37
  email: florian.hanke+picky-statistics@gmail.com
38
38
  executables: []