rhoconnect 3.3.6 → 3.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. data/CHANGELOG.md +40 -4
  2. data/Gemfile +2 -2
  3. data/Gemfile.lock +27 -25
  4. data/bench/benchapp/Gemfile +7 -27
  5. data/bench/benchapp/config.ru +9 -31
  6. data/bench/blobapp/Gemfile +7 -27
  7. data/bench/blobapp/config.ru +9 -29
  8. data/bench/lib/bench.rb +8 -1
  9. data/bench/lib/bench/test_data.rb +4 -1
  10. data/bench/scripts/blob_cud_script.rb +4 -0
  11. data/bench/scripts/cud_script.rb +7 -1
  12. data/bench/scripts/helpers.rb +1 -1
  13. data/bench/scripts/test_query_script.rb +20 -7
  14. data/bench/spec/bench_spec_helper.rb +3 -1
  15. data/bin/rhoconnect +22 -12
  16. data/commands/{commands/dtach_commands → dtach}/dtach_about.rb +0 -0
  17. data/commands/{commands/dtach_commands → dtach}/dtach_install.rb +0 -0
  18. data/commands/{commands/redis_commands → dtach}/redis_attach.rb +0 -0
  19. data/commands/execute.rb +14 -15
  20. data/commands/generators/update.rb +26 -0
  21. data/commands/{commands/redis_commands → redis}/redis_about.rb +0 -0
  22. data/commands/redis/redis_download.rb +13 -0
  23. data/commands/redis/redis_install.rb +26 -0
  24. data/commands/{commands/redis_commands → redis}/redis_make.rb +0 -0
  25. data/commands/{commands/redis_commands → redis}/redis_restart.rb +3 -2
  26. data/commands/{commands/redis_commands → redis}/redis_start.rb +0 -0
  27. data/commands/{commands/redis_commands → redis}/redis_startbg.rb +0 -0
  28. data/commands/{commands/redis_commands → redis}/redis_stop.rb +3 -2
  29. data/commands/{commands/rhoconnect → rhoconnect}/clean_start.rb +0 -0
  30. data/commands/{commands/rhoconnect → rhoconnect}/config.rb +7 -2
  31. data/commands/{commands/rhoconnect → rhoconnect}/create_user.rb +0 -0
  32. data/commands/{commands/rhoconnect → rhoconnect}/delete_device.rb +0 -0
  33. data/commands/{commands/rhoconnect → rhoconnect}/delete_user.rb +0 -0
  34. data/commands/{commands/rhoconnect → rhoconnect}/flushdb.rb +4 -4
  35. data/commands/{commands/rhoconnect → rhoconnect}/get_token.rb +0 -0
  36. data/commands/{commands/rhoconnect → rhoconnect}/reset.rb +0 -0
  37. data/commands/{commands/rhoconnect → rhoconnect}/reset_refresh.rb +0 -0
  38. data/commands/{commands/rhoconnect → rhoconnect}/restart.rb +0 -0
  39. data/commands/{commands/rhoconnect → rhoconnect}/secret.rb +0 -0
  40. data/commands/{commands/rhoconnect → rhoconnect}/set_admin_password.rb +0 -0
  41. data/commands/{commands/rhoconnect → rhoconnect}/spec.rb +0 -0
  42. data/commands/rhoconnect/start.rb +27 -0
  43. data/commands/{commands/rhoconnect → rhoconnect}/startbg.rb +0 -0
  44. data/commands/{commands/rhoconnect → rhoconnect}/startdebug.rb +2 -2
  45. data/commands/{commands/rhoconnect → rhoconnect}/stop.rb +3 -4
  46. data/commands/{commands/rhoconnect → rhoconnect}/version.rb +0 -0
  47. data/commands/{commands/rhoconnect → rhoconnect}/web.rb +0 -0
  48. data/commands/rhoconnect_attach/attach.rb +10 -0
  49. data/commands/rhoconnect_console/console.rb +16 -0
  50. data/commands/{commands/rhoconnect → rhoconnect_console}/console_helper.rb +0 -0
  51. data/commands/{commands/rhoconnect → rhoconnect_war}/war.rb +0 -0
  52. data/commands/{commands/redis_commands → utilities}/redis_runner.rb +22 -19
  53. data/commands/utilities/utilities.rb +6 -0
  54. data/doc/benchmarks.txt +2 -2
  55. data/doc/bulk-sync.txt +12 -1
  56. data/doc/client-java.txt +3 -3
  57. data/doc/client-objc.txt +1 -1
  58. data/doc/client.txt +5 -5
  59. data/doc/command-line.txt +80 -135
  60. data/doc/deploying.txt +119 -12
  61. data/doc/extending-rhoconnect-server.txt +1 -1
  62. data/doc/heroku-addon.txt +119 -23
  63. data/doc/install.txt +101 -39
  64. data/doc/java-plugin.txt +2 -2
  65. data/doc/licensing.txt +1 -1
  66. data/doc/plugin-intro.txt +3 -1
  67. data/doc/preparing-production.txt +4 -4
  68. data/doc/public/cli.txt +2 -2
  69. data/doc/push-backend-setup.txt +11 -1
  70. data/doc/push-client-setup.txt +72 -2
  71. data/doc/push-server-setup.txt +129 -8
  72. data/doc/rails-plugin.txt +245 -40
  73. data/doc/rest-api.txt +10 -6
  74. data/doc/rhoconnect-calculator.txt +237 -0
  75. data/doc/rhoconnect-redis-stack.txt +35 -0
  76. data/doc/session-and-configuration.txt +24 -0
  77. data/doc/settings.txt +51 -41
  78. data/doc/source-adapters.txt +45 -45
  79. data/doc/stats-middleware.txt +2 -2
  80. data/doc/supported-platforms.txt +6 -6
  81. data/doc/testing.txt +2 -2
  82. data/doc/tutorial.txt +63 -63
  83. data/examples/simple/Gemfile +7 -35
  84. data/examples/simple/config.ru +8 -26
  85. data/examples/simple/sources/product.rb +6 -6
  86. data/generators/rhoconnect.rb +5 -0
  87. data/generators/templates/application/Gemfile +7 -37
  88. data/generators/templates/application/Rakefile +8 -0
  89. data/generators/templates/application/config.ru +12 -31
  90. data/generators/templates/application/rcgemfile +44 -0
  91. data/generators/templates/application/settings/settings.yml +7 -5
  92. data/install.sh +4 -4
  93. data/installer/unix-like/create_texts.rb +7 -2
  94. data/installer/unix-like/rho_connect_install_constants.rb +2 -2
  95. data/installer/unix-like/rho_connect_install_installers.rb +1 -16
  96. data/lib/rhoconnect.rb +51 -38
  97. data/lib/rhoconnect/api/app/query.rb +4 -1
  98. data/lib/rhoconnect/api/app/search.rb +4 -1
  99. data/lib/rhoconnect/api/client/list_client_docs.rb +3 -1
  100. data/lib/rhoconnect/api/user/ping.rb +1 -5
  101. data/lib/rhoconnect/application/init.rb +43 -0
  102. data/lib/rhoconnect/async.rb +11 -6
  103. data/lib/rhoconnect/client_sync.rb +30 -37
  104. data/lib/rhoconnect/document.rb +4 -0
  105. data/lib/rhoconnect/graph_helper.rb +74 -56
  106. data/lib/rhoconnect/middleware/helpers.rb +4 -0
  107. data/lib/rhoconnect/ping.rb +1 -0
  108. data/lib/rhoconnect/ping/gcm.rb +58 -0
  109. data/lib/rhoconnect/predefined_adapters/bench_adapter.rb +7 -1
  110. data/lib/rhoconnect/source.rb +70 -56
  111. data/lib/rhoconnect/source_sync.rb +33 -5
  112. data/lib/rhoconnect/store.rb +358 -110
  113. data/lib/rhoconnect/user.rb +8 -0
  114. data/lib/rhoconnect/utilities.rb +16 -14
  115. data/lib/rhoconnect/version.rb +1 -1
  116. data/lib/rhoconnect/web-console/models/client.js +1 -1
  117. data/lib/rhoconnect/web-console/public/UNVR67bold.ttf +0 -0
  118. data/lib/rhoconnect/web-console/public/bootstrap.css +6 -0
  119. data/lib/rhoconnect/web-console/public/logo.png +0 -0
  120. data/lib/rhoconnect/web-console/server.rb +13 -11
  121. data/lib/rhoconnect/web-console/templates/index.erb +5 -5
  122. data/lib/rhoconnect/web-console/templates/jqplot.erb +1 -0
  123. data/lib/rhoconnect/web-console/views/doc.js +0 -4
  124. data/lib/rhoconnect/web-console/views/home.js +2 -1
  125. data/lib/rhoconnect/web-console/views/new_ping.js +11 -6
  126. data/lib/rhoconnect/web-console/views/stats.js +9 -5
  127. data/rhoconnect.gemspec +6 -4
  128. data/spec/api/app/fast_update_spec.rb +2 -2
  129. data/spec/api/source/get_source_params_spec.rb +1 -0
  130. data/spec/apps/rhotestapp/settings/settings.yml +5 -5
  131. data/spec/client_sync_spec.rb +3 -14
  132. data/spec/perf/perf_spec_helper.rb +11 -7
  133. data/spec/perf/store_perf_spec.rb +88 -11
  134. data/spec/ping/gcm_spec.rb +99 -0
  135. data/spec/server/server_spec.rb +7 -0
  136. data/spec/server/stats_spec.rb +9 -2
  137. data/spec/source_sync_spec.rb +29 -0
  138. data/spec/spec_helper.rb +40 -38
  139. data/spec/stats/record_spec.rb +18 -9
  140. data/spec/store_spec.rb +128 -19
  141. data/spec/testdata/10000-data.txt +0 -0
  142. data/spec/testdata/5-data.txt +0 -0
  143. data/spec/testdata/5000-data.txt +0 -0
  144. data/tasks/jasmine.rake +1 -0
  145. data/tasks/redis.rake +16 -13
  146. metadata +71 -39
  147. data/commands/commands/redis_commands/redis_download.rb +0 -33
  148. data/commands/commands/redis_commands/redis_install.rb +0 -26
  149. data/commands/commands/rhoconnect/attach.rb +0 -8
  150. data/commands/commands/rhoconnect/console.rb +0 -15
  151. data/commands/commands/rhoconnect/start.rb +0 -18
  152. data/commands/utilities/dtach_installed.rb +0 -10
@@ -1,4 +1,7 @@
1
1
  Server.api4 :query, :get, "/app/#{Rhoconnect::API_VERSION}/:source_name", false, {:verb => :get, :url => ['/api/application', '/application', '/api/application/query']} do |params,user,server|
2
2
  server.content_type :json
3
- res = server.current_client_sync.send_cud(params[:token],params[:query]).to_json
3
+ res = server.current_client_sync.send_cud(params[:token],params[:query])
4
+ server.response.headers[Rhoconnect::PAGE_TOKEN_HEADER] = res[1]['token']
5
+ server.response.headers[Rhoconnect::PAGE_OBJECT_COUNT_HEADER] = res[2]['count'].to_s
6
+ res.to_json
4
7
  end
@@ -1,4 +1,7 @@
1
1
  Server.api4 :search, :post, "/rc/#{Rhoconnect::API_VERSION}/app/search", false, {:verb => :get, :url => ['/application/search', '/api/application/search']} do |params,user,server|
2
2
  server.content_type :json
3
- ClientSync.search_all(server.current_client,params).to_json
3
+ res = ClientSync.search_all(server.current_client,params)
4
+ server.response.headers[Rhoconnect::PAGE_TOKEN_HEADER] = res[0][1]['token'] if res[0][1] and res[0][1]['token']
5
+ server.response.headers[Rhoconnect::PAGE_OBJECT_COUNT_HEADER] = res[0][3]['count'].to_s if res[0][3] and res[0][3]['count']
6
+ res.to_json
4
7
  end
@@ -1,5 +1,6 @@
1
1
  Server.api4 :list_client_docs, :get, "/rc/#{Rhoconnect::API_VERSION}/clients/:client_id/sources/:source_id/docnames", \
2
2
  true, {:verb => :post, :url => ['/api/list_client_docs', '/api/client/list_client_docs']} do |params,user|
3
+ result = ""
3
4
  Rhoconnect::Stats::Record.update('clientdocs') do
4
5
  c = Client.load(params[:client_id],{:source_name => params[:source_id]})
5
6
  res = {}
@@ -10,6 +11,7 @@ Server.api4 :list_client_docs, :get, "/rc/#{Rhoconnect::API_VERSION}/clients/:cl
10
11
  db_key = c.docname(doc)
11
12
  res.merge!(doc => db_key)
12
13
  end
13
- res.to_json
14
+ result = res.to_json
14
15
  end
16
+ result
15
17
  end
@@ -1,7 +1,3 @@
1
1
  Server.api4 :ping, :post, "/rc/#{Rhoconnect::API_VERSION}/users/ping", true, {:verb => :post, :url => ['/api/ping', '/api/client/ping']} do |params,user|
2
- if params['async']
3
- PingJob.enqueue(params)
4
- else
5
- PingJob.perform(params)
6
- end
2
+ User.ping(params)
7
3
  end
@@ -0,0 +1,43 @@
1
+ # Application root path
2
+ require 'rubygems'
3
+ require 'bundler'
4
+ Bundler.require
5
+
6
+ ROOT_PATH = File.expand_path('.')
7
+
8
+ # Debugger support
9
+ if ENV['DEBUG'] == 'yes'
10
+ ENV['APP_TYPE'] = 'rhosync'
11
+ ENV['ROOT_PATH'] = ROOT_PATH
12
+ require 'debugger'
13
+ end
14
+
15
+ require 'rhoconnect/server'
16
+ require 'rhoconnect/web-console/server'
17
+ require 'resque/server'
18
+
19
+ # Rhoconnect server flags
20
+ #Rhoconnect::Server.enable :stats
21
+ Rhoconnect::Server.disable :run
22
+ Rhoconnect::Server.disable :clean_trace
23
+ Rhoconnect::Server.enable :raise_errors
24
+ Rhoconnect::Server.set :root, ROOT_PATH
25
+ Rhoconnect::Server.use Rack::Static, :urls => ['/data'], :root => Rhoconnect::Server.root
26
+ # disable Async mode if Debugger is used
27
+ if ENV['DEBUG'] == 'yes'
28
+ Rhoconnect::Server.set :use_async_model, false
29
+ end
30
+
31
+ module Rhoconnect
32
+ def app
33
+ # Setup the url map
34
+ url_map = { '/' => Rhoconnect::Server.new }
35
+ unless Rhoconnect.disable_resque_console
36
+ url_map['/resque'] = Resque::Server.new
37
+ end
38
+ unless Rhoconnect.disable_rc_console
39
+ url_map['/console'] = RhoconnectConsole::Server.new
40
+ end
41
+ return Rack::URLMap.new url_map
42
+ end
43
+ end
@@ -51,13 +51,18 @@ module Rhoconnect
51
51
  def execute_api_call(client_call = false)
52
52
  f = Fiber.current
53
53
  operation = proc {
54
- catch_all do
55
- res = yield params, current_user, self
56
- if params.has_key? :warning
57
- Rhoconnect.log params[:warning]
58
- response.headers['Warning'] = params[:warning]
54
+ self.request.env['REQUEST_THREAD'] = Thread.current
55
+ if(request.env['RHO_ABORT_PROCESS'])
56
+ res = [500, 'Request is aborted']
57
+ else
58
+ catch_all do
59
+ res = yield params, current_user, self
60
+ if params.has_key? :warning
61
+ Rhoconnect.log params[:warning]
62
+ response.headers['Warning'] = params[:warning]
63
+ end
64
+ res
59
65
  end
60
- res
61
66
  end
62
67
  }
63
68
  result = nil
@@ -74,8 +74,7 @@ module Rhoconnect
74
74
  else
75
75
  compute_errors_page
76
76
  res = build_page do |r|
77
- total_count,r['insert'] = compute_page
78
- r['delete'] = compute_deleted_page
77
+ total_count,r['insert'],r['delete'] = compute_page
79
78
  r['links'] = compute_links_page
80
79
  r['metadata'] = compute_metadata
81
80
  end
@@ -84,13 +83,11 @@ module Rhoconnect
84
83
  else
85
84
  _delete_errors_page
86
85
  end
87
- @client.put_data(:cd,res['insert'],true)
88
- @client.delete_data(:cd,res['delete'])
89
- # TODO: progress count can not be computed properly
90
- # without comparing what has actually changes
91
- # so we need to obsolete it in the future versions
92
- progress_count = 0
93
86
  end
87
+ # TODO: progress count can not be computed properly
88
+ # without comparing what has actually changes
89
+ # so we need to obsolete it in the future versions
90
+ progress_count = 0
94
91
  [token,progress_count,total_count,res]
95
92
  end
96
93
 
@@ -167,52 +164,48 @@ module Rhoconnect
167
164
  # Computes diffs between master doc and client doc, trims it to page size,
168
165
  # stores page, and returns page as hash
169
166
  def compute_page
170
- res,total_count = @source.lock(:md) do |s|
171
- res = Store.get_diff_data(@client.docname(:cd),s.docname(:md),@p_size)
167
+ inserts_elements_map,deletes_elements_map,total_count = @source.lock(:md) do |s|
168
+ inserts_elements_map = Store.get_diff_data(@client.docname(:cd),s.docname(:md),@p_size)
172
169
  total_count = s.get_value(:md_size).to_i
173
- [res,total_count]
170
+ deletes_elements_map = Store.get_diff_data(s.docname(:md),@client.docname(:cd),@p_size)
171
+ [inserts_elements_map,deletes_elements_map,total_count]
174
172
  end
175
173
  # until sync is not done - set cd_size to 0
176
174
  # once there are no changes, then, set cd_size to md_size
177
- cd_size = res.size > 0 ? 0 : total_count
175
+ cd_size = inserts_elements_map.size > 0 ? 0 : total_count
178
176
  @client.put_value(:cd_size, cd_size)
179
- @client.put_data(:page,res)
177
+
178
+ # now, find the exact changes
179
+ inserts,deletes = Store.get_inserts_deletes(inserts_elements_map,deletes_elements_map)
180
+
181
+ @client.put_data(:page,inserts)
182
+ @client.put_data(:delete_page,deletes,true)
180
183
  @client.put_value(:total_count_page,total_count)
181
- [total_count,res]
184
+ Store.update_elements(@client.docname(:cd),inserts_elements_map,deletes_elements_map)
185
+
186
+ [total_count,inserts,deletes]
182
187
  end
183
188
 
184
189
  # Computes search result, updates md for source and cd for client with the result
185
190
  def compute_search
186
- client_res = Store.get_diff_data(@client.docname(:cd),@client.docname(:search),@p_size)
187
- @client.put_data(:cd,client_res,true)
188
- @client.update_count(:cd_size,client_res.size)
189
- @client.put_data(:search_page,client_res)
191
+ cd_inserts_elements_map = Store.get_diff_data(@client.docname(:cd),@client.docname(:search),@p_size)
192
+
193
+ Store.update_elements(@client.docname(:cd), cd_inserts_elements_map, {})
194
+ @client.update_count(:cd_size,cd_inserts_elements_map.size)
195
+ # remove previous search page and build new one
196
+ @client.flash_data(:search_page)
197
+ Store.update_elements(@client.docname(:search_page),cd_inserts_elements_map,{})
198
+ client_res = @client.get_data(:search_page)
190
199
 
191
200
  @source.lock(:md) do |s|
192
- source_diff = Store.get_diff_data(s.docname(:md),@client.docname(:cd))
193
- s.put_data(:md,source_diff,true)
194
- s.update_count(:md_size,source_diff.size)
201
+ md_inserts_elements_map = Store.get_diff_data(s.docname(:md),@client.docname(:cd))
202
+ Store.update_elements(s.docname(:md), md_inserts_elements_map, {})
203
+ s.update_count(:md_size,md_inserts_elements_map.size)
195
204
  end
196
205
 
197
206
  [client_res,client_res.size]
198
207
  end
199
208
 
200
- # Computes deleted objects (down to individual attributes)
201
- # in the client document, trims it to page size, stores page, and returns page as hash
202
- def compute_deleted_page
203
- res = {}
204
- delete_page_doc = @client.docname(:delete_page)
205
- page_size = @p_size
206
- diff = @source.lock(:md) { |s| Store.get_diff_data(s.docname(:md),@client.docname(:cd),@p_size) }
207
- diff.each do |key,value|
208
- res[key] = value
209
- Store.put_object(delete_page_doc,key,value)
210
- page_size -= 1
211
- break if page_size <= 0
212
- end
213
- res
214
- end
215
-
216
209
  # Computes errors for client and stores a copy as errors page
217
210
  def compute_errors_page
218
211
  ['create','update','delete'].each do |operation|
@@ -9,6 +9,10 @@ module Document
9
9
  Store.get_object(docname(doctype), key)
10
10
  end
11
11
 
12
+ def get_objects(doctype, keys)
13
+ Store.get_objects(docname(doctype), keys)
14
+ end
15
+
12
16
  def get_list(doctype)
13
17
  Store.get_list(docname(doctype))
14
18
  end
@@ -5,11 +5,7 @@ module GraphHelper
5
5
  #name,data,options
6
6
  @displayname = params['display_name']
7
7
  names = []
8
- # begin
9
- # names = get_sources('all')
10
- # rescue Exception => e
11
- # puts "errror #{e.message}"
12
- # end
8
+
13
9
  names = [params['display_name']]
14
10
  @sources = []
15
11
 
@@ -61,14 +57,13 @@ module GraphHelper
61
57
  s['data'] = data
62
58
  options[:series] = series
63
59
  options[:cursor] = {:zoom => true, :showTooltip => true}
64
-
60
+ options[:seriesDefaults] = {:pointLabels => { :show=>true }}
65
61
  s['options'] = options
66
62
  end
67
63
 
68
64
  @sources << s
69
65
  end
70
- @graph_t = 'source'
71
- @data = [[[1,2],[3,4],[5,6]]].to_json
66
+
72
67
  erb :jqplot, :layout => false
73
68
  end
74
69
 
@@ -78,19 +73,14 @@ module GraphHelper
78
73
 
79
74
  #name,data,options
80
75
  @displayname = params['display_name']
81
- #names = ["GET","POST"]
82
- # begin
83
- # names = get_sources('all')
84
- # rescue Exception => e
85
- # puts "errror #{e.message}"
86
- # end
76
+
87
77
  @sources = []
88
78
  name = key = params['display_name']
89
79
 
90
80
  s = {}
91
81
  data = []
92
82
  series = []
93
- options = { :legend => { :show => true, :location => 'ne' }, :title => name }
83
+ options = { :legend => { :show => false }, :title => name }
94
84
  s['name'] = name
95
85
 
96
86
  xmin = 9999999999999999
@@ -98,43 +88,46 @@ module GraphHelper
98
88
  ymin = 9999999999999999
99
89
  ymax = -1
100
90
 
101
- method = key.gsub(/http:.*?:/,"")
102
- #method.gsub!(/:.*/,"")
103
- series << {:showLabel => true, :label => method}
104
- range = get_user_count(nil,key,0,-1)
105
- thisdata = []
106
- range.each do |value|
107
- count = value.split(',')[0]
108
- value.gsub!(/.*,/,"")
109
- thisdata << value.split(":").reverse
110
- thisdata[-1][0] = thisdata[-1][0].to_i * 1000
111
- thisdata[-1][1] = thisdata[-1][1].to_f
112
- thisdata[-1][1] /= count.to_f
113
-
114
- ymin = thisdata[-1][1].to_f if thisdata[-1][1] && thisdata[-1][1].to_f < ymin
115
- ymax = thisdata[-1][1].to_f if thisdata[-1][1] && thisdata[-1][1].to_f > ymax
91
+ keys = Rhoconnect::Stats::Record.keys(key)
92
+
93
+ keys.each_with_index do |k,index|
94
+ method = key.gsub(/http:.*?:/,"")
95
+ #method.gsub!(/:.*/,"") unless name == "*"
96
+ series << {:showLabel => true, :label => method, :showLine => false }
116
97
 
98
+ range = get_user_count(nil,k,0,-1)
99
+ thisdata = []
100
+ range.each do |value|
101
+ count = value.split(',')[0]
102
+ value.gsub!(/.*,/,"")
103
+ thisdata << value.split(":").reverse
104
+ thisdata[-1][0] = thisdata[-1][0].to_i * 1000
105
+ thisdata[-1][1] = thisdata[-1][1].to_f
106
+ thisdata[-1][1] /= count.to_f
107
+ end
108
+ data << thisdata
109
+ xmin = thisdata[0][0].to_i if thisdata[0] && thisdata[0][0].to_i < xmin
110
+ xmax = thisdata[-1][0].to_i if thisdata[-1] && thisdata[-1][0].to_i > xmax
117
111
  end
118
- data << thisdata
119
- xmin = thisdata[0][0].to_i if thisdata[0] && thisdata[0][0].to_i < xmin
120
- xmax = thisdata[-1][0].to_i if thisdata[-1] && thisdata[-1][0].to_i > xmax
121
-
122
-
112
+
113
+ data_normalized,ymin,ymax,days = average_data(data,ymin,ymax)
114
+ #puts "dn is ****************** #{data_normalized}"
115
+ format_str = days ? "%m/%d%y" : "%H"
116
+ label_time = days ? "Days" : "#{data_normalized.first.first[0].year}-#{data_normalized.first.first[0].month}-#{data_normalized.first.first[0].day} (Hours)"
117
+
123
118
  options[:axes] = {
124
119
  :yaxis => { :tickOptions => { :formatString =>'%.3f'}, :autoscale => true, :min => 0, :max => ymax + (ymax * 0.05), :label => 'Seconds', :labelRenderer => '$.jqplot.CanvasAxisLabelRenderer' },
125
- :xaxis => { :autoscale => true, :renderer=>'$.jqplot.DateAxisRenderer',
126
- :tickOptions => {:formatString => '%m/%d/%y'}}
120
+ :xaxis => { :autoscale => true, :label => label_time, :renderer=>'$.jqplot.DateAxisRenderer',
121
+ :tickOptions => {:formatString => format_str}}
127
122
  }
128
-
129
- s['data'] = data
123
+ s['data'] = data_normalized
130
124
  options[:series] = series
131
- options[:cursor] = {:zoom => true, :showTooltip => true}
125
+ options[:cursor] = {:zoom => true, :showTooltip => true, :show => true}
126
+ options[:seriesDefaults] = {:pointLabels => { :show=>true },:rendererOptions => {:smooth => true}}
132
127
  s['options'] = options
133
128
 
134
129
  @sources << s
135
130
 
136
- @graph_t = 'http'
137
- @data = [[[1,2],[3,4],[5,6]]].to_json
138
131
  erb :jqplot, :layout => false
139
132
  end
140
133
 
@@ -194,7 +187,8 @@ module GraphHelper
194
187
 
195
188
  s['data'] = data
196
189
  options[:series] = series
197
- options[:cursor] = {:zoom => true, :showTooltip => true}
190
+ options[:cursor] = {:zoom => true, :showTooltip => true}
191
+ options[:seriesDefaults] = {:rendererOptions => {:smooth => true}}
198
192
  s['options'] = options
199
193
 
200
194
  @sources << s
@@ -207,19 +201,11 @@ module GraphHelper
207
201
 
208
202
  def get_http_routes()
209
203
  keys = get_user_count("http:*:*")
210
- method = key.gsub(/http:.*?:/,"")
211
- #sources = get_sources('all')
212
-
213
- #loop through arrays and remove any regex matches
214
- # keysf = keys.inject([]) do |keys_final, element|
215
- # found = true
216
- # sources.each do |s|
217
- # found = false if element.match(s)
218
- # end
219
- # keys_final << element.strip if found
220
- # keys_final
221
- # end
222
-
204
+ keys.each do |k|
205
+ client_id = k.split("/")[4]
206
+ k.gsub!(client_id,"*") if client_id
207
+ end
208
+ keys.uniq
223
209
  end
224
210
 
225
211
  def count_graph(uri,title,name,metric)
@@ -253,6 +239,7 @@ module GraphHelper
253
239
  }
254
240
 
255
241
  options[:cursor] = {:zoom => true, :showTooltip => true}
242
+ options[:seriesDefaults] = {:pointLabels => { :show=>true },:rendererOptions => {:smooth => true}}
256
243
  s['name'] = name
257
244
  s['data'] = [thisdata]
258
245
  s['options'] = options
@@ -303,7 +290,38 @@ module GraphHelper
303
290
  end
304
291
  res
305
292
  end
293
+ end
294
+
295
+ def average_data(data,ymin,ymax)
296
+ data_buckets = {}
297
+ data_count = {}
298
+ data_result = []
299
+ days = false
300
+
301
+ data.each do |d_arr|
302
+ bucket = Time.at(d_arr.first[0]/1000)
303
+ bucket_key = "#{bucket.year}-#{bucket.month}-#{bucket.day} #{bucket.hour}:0:0"
304
+ if data_buckets.include? bucket_key
305
+ data_buckets[bucket_key] += d_arr.first[1]
306
+ data_count[bucket_key] += 1
307
+ else
308
+ data_buckets[bucket_key] = d_arr.first[1]
309
+ data_count[bucket_key] = 1
310
+ end
311
+ ymin = d_arr.first[1].to_f if d_arr.first[1].to_f < ymin.to_f
312
+ ymax = d_arr.first[1].to_f if d_arr.first[1].to_f > ymax.to_f
313
+ end
314
+ data_buckets.each do |index,value|
315
+ average_val = value/data_count[index]
316
+ data_result << [[Time.at(Time.parse(index).to_i),average_val.round(3)]]
317
+ end
306
318
 
319
+ unless data_buckets.size < 2
320
+ start_day = Time.parse(data_buckets.first.first)
321
+ end_day = Time.parse(data_buckets.last.first)
322
+ days = true if start_day.month != end_day.month and start_day.day != end_day.day
323
+ end
324
+ return data_result,ymin,ymax,days
307
325
  end
308
326
 
309
327
  end
@@ -10,6 +10,10 @@ module Rhoconnect
10
10
  API_TOKEN_HEADER = 'HTTP_X_RHOCONNECT_API_TOKEN'.freeze
11
11
  # X-RhoConnect-CLIENT-ID
12
12
  CLIENT_ID_HEADER = 'HTTP_X_RHOCONNECT_CLIENT_ID'.freeze
13
+ # X-RhoConnect-PAGE-TOKEN
14
+ PAGE_TOKEN_HEADER = 'X-Rhoconnect-PAGE-TOKEN'
15
+ # X-RhoConnect-PAGE-OBJECT-COUNT
16
+ PAGE_OBJECT_COUNT_HEADER = 'X-Rhoconnect-PAGE-OBJECT-COUNT'
13
17
 
14
18
  # old-way admin routes
15
19
  OLD_API_URI_REGEXP = /\/api\//