prosperity 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/prosperity/application.js.coffee +5 -24
- data/app/assets/javascripts/prosperity/dashboards.js.coffee +17 -0
- data/app/assets/javascripts/prosperity/graph.js.coffee +89 -0
- data/app/assets/stylesheets/prosperity/application.css.scss +1 -1
- data/app/assets/stylesheets/prosperity/dashboards.css +4 -0
- data/app/assets/stylesheets/prosperity/graph.css +4 -0
- data/app/controllers/prosperity/application_controller.rb +30 -0
- data/app/controllers/prosperity/dashboard_graphs_controller.rb +24 -0
- data/app/controllers/prosperity/dashboards_controller.rb +33 -0
- data/app/controllers/prosperity/graphs_controller.rb +72 -0
- data/app/controllers/prosperity/metrics_controller.rb +57 -0
- data/app/helpers/prosperity/application_helper.rb +4 -0
- data/app/helpers/prosperity/dashboard_graphs_helper.rb +4 -0
- data/app/helpers/prosperity/dashboards_helper.rb +4 -0
- data/app/helpers/prosperity/graph_helper.rb +7 -0
- data/app/models/prosperity/dashboard.rb +8 -0
- data/app/models/prosperity/dashboard_graph.rb +6 -0
- data/app/models/prosperity/graph.rb +20 -0
- data/app/models/prosperity/graph_line.rb +8 -0
- data/app/views/layouts/prosperity/application.html.erb +56 -0
- data/app/views/prosperity/dashboards/edit.html.erb +24 -0
- data/app/views/prosperity/dashboards/index.html.erb +15 -0
- data/app/views/prosperity/dashboards/new.html.erb +8 -0
- data/app/views/prosperity/dashboards/show.html.erb +14 -0
- data/app/views/prosperity/graphs/edit.html.erb +41 -0
- data/app/views/prosperity/graphs/new.html.erb +15 -0
- data/app/views/prosperity/metrics/index.html.erb +8 -0
- data/app/views/prosperity/metrics/show.html.erb +23 -0
- data/app/views/prosperity/shared/_date_range.html.erb +9 -0
- data/config/routes.rb +12 -2
- data/db/migrate/20131127042251_dashboards.rb +34 -0
- data/lib/generators/metric/USAGE +8 -0
- data/lib/generators/metric/metric_generator.rb +7 -0
- data/lib/generators/metric/templates/metric.rb.erb +3 -0
- data/lib/prosperity/aggregate/aggregate_builder.rb +42 -0
- data/lib/prosperity/aggregate/average.rb +12 -0
- data/lib/prosperity/aggregate/base.rb +5 -0
- data/lib/prosperity/aggregate/count.rb +12 -0
- data/lib/prosperity/aggregate/maximum.rb +12 -0
- data/lib/prosperity/aggregate/minimum.rb +12 -0
- data/lib/prosperity/aggregate/sql.rb +12 -0
- data/lib/prosperity/aggregate/sum.rb +12 -0
- data/lib/prosperity/aggregate/with_column.rb +10 -0
- data/lib/prosperity/aggregate.rb +5 -0
- data/lib/prosperity/engine.rb +14 -0
- data/lib/prosperity/exception.rb +19 -1
- data/lib/prosperity/extractors/base.rb +33 -5
- data/lib/prosperity/extractors/change.rb +35 -0
- data/lib/prosperity/extractors/interval.rb +51 -0
- data/lib/prosperity/extractors/total.rb +23 -0
- data/lib/prosperity/helpers/time.rb +12 -0
- data/lib/prosperity/metric.rb +90 -5
- data/lib/prosperity/metric_finder.rb +10 -0
- data/lib/prosperity/metrics/option.rb +2 -0
- data/lib/prosperity/period.rb +4 -3
- data/lib/prosperity/periods.rb +13 -2
- data/lib/prosperity/version.rb +1 -1
- data/spec/controllers/prosperity/dashboard_graphs_controller_spec.rb +45 -0
- data/spec/controllers/prosperity/dashboards_controller_spec.rb +54 -0
- data/spec/controllers/prosperity/graphs_controller_spec.rb +145 -0
- data/spec/controllers/prosperity/metrics_controller_spec.rb +78 -0
- data/spec/dummy/app/models/user.rb +1 -0
- data/spec/dummy/app/prosperity/user_value_sum_metric.rb +4 -0
- data/spec/dummy/app/prosperity/user_value_sum_sql_metric.rb +4 -0
- data/spec/dummy/app/prosperity/users_metric.rb +8 -0
- data/spec/dummy/app/prosperity/users_sql_metric.rb +4 -0
- data/spec/dummy/config/database.yml +0 -8
- data/spec/dummy/config/routes.rb +1 -1
- data/spec/dummy/db/migrate/20140217005117_add_value_to_users.rb +5 -0
- data/spec/dummy/db/schema.rb +37 -1
- data/spec/dummy/db/seeds.rb +3 -1
- data/spec/dummy/log/development.log +76950 -0
- data/spec/dummy/log/test.log +111316 -0
- data/spec/dummy/tmp/cache/assets/development/sass/34a577735054231563e7022ea73e1468db9203ba/application.css.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/07e8fb2db7d85e29590a6b05160ca825 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1533bcf4a8f5a745dfda80cebd88d217 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1643e7f9f85637df140a850af6674f10 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/197492ed379339e17a0f5d01d3b01b8c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1c55cf24465f311353197ce336df0178 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/210050da208fb75a75b701bfa4e8470f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2733033a48e2e8a6fdd6e4ab371689ee +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/27a59e08207d3ae723f2b2b3d22264c3 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3e21790900d62ae3954585f08a1cb28a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3f76425644a701b85db3d385f077052d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/448c1e44da04c20f27eaa31ad8c4391e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/47df4fdca8a2ff6a43c18d7aa1ffd9c5 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/566fbede2036fd06a20e7e52e30ddc7d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/5f1aaf22720701db690538726e896a39 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/647038c58f26163a9217646e1e5f09ae +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6882b260ae69f1594eff540d803e5ac3 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/69f4b83d363269ee4122bbbaaa1325d1 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6e1aee34907ba1ccdbfca2deb18a5adb +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/72c0d4a0eeedae5e79ae49abb24f6d32 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/828a046f0e7dc2dad0eecfe49d31e14d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/91ae0bd43f98b4f1f111e0bdc178302c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/97d99b466bedb69706f4815fa26b69f3 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/990cf740a7968767a327f6186313badb +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a2b14d5c46db32da9183354fb3fcd0bf +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a6d6196cfd275dea0718553a95f997a5 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/bb1f5ffb0ccbeec2c6499044b356f7c6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/bc83340720a76d8208112f6aecbff08e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/be67cef79122a71f7432c2f984f1f258 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c83e71ece967e80f8df838874c130431 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cad26971ff72bbf5aa5f4e6a469389eb +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d0d5517256edcd1f83b11a13c6ca040f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d0f0c5e105bfb1d6e5cd7295fbd1f65d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d3087f7df919b7f0d8142ee163db6c79 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/decc27a1fa9ea32fe0dcc18619e32587 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/df796f7ea525be06a82ebc3a4f97ffec +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e02b5049cf477b43a72b4a00e2fceb46 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e2a9bdd87a2d19256837fce6544a122c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e378dcebf3c529db0d6e57d0c8dc3904 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ee3031bd54230ddf2addb5fa5718c86b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f4648036e284d9aa3468f4f7b9bbb967 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f9bbf698d099ead559e5ba4a5a4c5538 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/fb8d3825617fcc11dfa614a51effee0e +0 -0
- data/spec/dummy/tmp/cache/assets/test/sass/34a577735054231563e7022ea73e1468db9203ba/application.css.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/07e8fb2db7d85e29590a6b05160ca825 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0a40fa5e0d6c0de40a8a698dcd697305 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/1533bcf4a8f5a745dfda80cebd88d217 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/1643e7f9f85637df140a850af6674f10 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/177ca1f3e92db4f8a8f6e7ad9786ebfc +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/197492ed379339e17a0f5d01d3b01b8c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/1c55cf24465f311353197ce336df0178 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/1cb94582c835e73b3fd3c276f9a7de56 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/203047a4141cf08162077e7290421bbb +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/210050da208fb75a75b701bfa4e8470f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2733033a48e2e8a6fdd6e4ab371689ee +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/27a59e08207d3ae723f2b2b3d22264c3 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/29a6c93aeb91d07a5533b3adba7697d0 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/29ac2be474969468157245a7f8737fa4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/314e44d29ecc7449c9ca3b754329c245 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/3162d1398d6940ee5e933b7ab4d2273d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/3d80e2a5faaf2bd987d804c17aead745 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/4155a156cc6ffb880b56dbc34346fbc0 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/4166fe47cddf4ba18c53b843d69b4c5f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/441f922b26aae90d40e319b6ed0a3bc8 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/4432a4b71ce9551df8d4b3860f4b9be3 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/448c1e44da04c20f27eaa31ad8c4391e +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/47df4fdca8a2ff6a43c18d7aa1ffd9c5 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5479c7b4fba9179d4d1dc59ae64964c1 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/566fbede2036fd06a20e7e52e30ddc7d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5a3ab9afd151c265cf11c621c0ddbe00 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/647038c58f26163a9217646e1e5f09ae +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/64e0150fafbd9aaa3822efa1abb0211d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/65c2d908dbca1bc833ae0b552f6c27fa +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6882b260ae69f1594eff540d803e5ac3 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/69f4b83d363269ee4122bbbaaa1325d1 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6e1aee34907ba1ccdbfca2deb18a5adb +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/726d3f6850549a59954f0bf5584cfd9f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7ab9ac7cc2529219a4c68fd7854d5c0f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7bac3aca131c870ad5b07d8ccdc86e06 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/80392355fc6e00cf69b2cd46978ebcbe +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/874b42463fefbb0bce47775722ebb4ae +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/87ef8ddd2847d19f22a16d726b88b433 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/91ae0bd43f98b4f1f111e0bdc178302c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/97d99b466bedb69706f4815fa26b69f3 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/990cf740a7968767a327f6186313badb +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/9a690664139b0393787d6454b4697183 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a2b14d5c46db32da9183354fb3fcd0bf +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a6d6196cfd275dea0718553a95f997a5 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/bc83340720a76d8208112f6aecbff08e +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c29c465933e7e86d6f6224f5e78c5baf +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c975834a35907ecd2d314bbd6844ee88 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/cad26971ff72bbf5aa5f4e6a469389eb +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/cf4affc50c6303e717d6514380d1f417 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d0d5517256edcd1f83b11a13c6ca040f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d3087f7df919b7f0d8142ee163db6c79 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d8b357d5741711da2dd710af0e15d268 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/decc27a1fa9ea32fe0dcc18619e32587 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/df796f7ea525be06a82ebc3a4f97ffec +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e22a1b318499e7f06ea9274e18ab004f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e298cc3a8203ab1fb6978a90254f8926 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e378dcebf3c529db0d6e57d0c8dc3904 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e868f358fe87542c483951a2d9f532b6 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e8a6adf580ebd1942f4aabe6738678c2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/ed71f99e0a9653296abd5d6f501dd898 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/efe6f2d16d3a1819817efb8734daf8af +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f03e99bdb4159ae3485ca2858716e19b +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f4648036e284d9aa3468f4f7b9bbb967 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f961f7434a28c0fe24bf4ffe6cba75fb +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f9bbf698d099ead559e5ba4a5a4c5538 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/fb8d3825617fcc11dfa614a51effee0e +0 -0
- data/spec/helpers/prosperity/dashboard_graphs_helper_spec.rb +6 -0
- data/spec/helpers/prosperity/dashboards_helper_spec.rb +6 -0
- data/spec/helpers/prosperity/{metrics_helper_spec.rb → graph_helper_spec.rb} +1 -1
- data/spec/lib/prosperity/aggregate/aggregate_builder_spec.rb +65 -0
- data/spec/lib/prosperity/aggregate/average_spec.rb +7 -0
- data/spec/lib/prosperity/aggregate/base_spec.rb +7 -0
- data/spec/lib/prosperity/aggregate/count_spec.rb +7 -0
- data/spec/lib/prosperity/aggregate/maximum_spec.rb +7 -0
- data/spec/lib/prosperity/aggregate/minimum_spec.rb +7 -0
- data/spec/lib/prosperity/aggregate/sql_spec.rb +7 -0
- data/spec/lib/prosperity/aggregate/sum_spec.rb +7 -0
- data/spec/lib/prosperity/aggregate/with_column_spec.rb +7 -0
- data/spec/lib/prosperity/aggregate_spec.rb +7 -0
- data/spec/lib/prosperity/extractors/base_spec.rb +27 -2
- data/spec/lib/prosperity/extractors/change_spec.rb +72 -0
- data/spec/lib/prosperity/extractors/interval_spec.rb +153 -0
- data/spec/lib/prosperity/extractors/total_spec.rb +79 -0
- data/spec/lib/prosperity/helpers/time_spec.rb +7 -0
- data/spec/lib/prosperity/metric_finder_spec.rb +7 -0
- data/spec/lib/prosperity/metric_spec.rb +126 -1
- data/spec/lib/prosperity/periods_spec.rb +14 -0
- data/spec/models/prosperity/dashboard_graph_spec.rb +6 -0
- data/spec/models/prosperity/dashboard_spec.rb +6 -0
- data/spec/models/prosperity/graph_line_spec.rb +6 -0
- data/spec/models/prosperity/graph_spec.rb +6 -0
- data/spec/spec_helper.rb +5 -2
- data/spec/support/shared/extractors.rb +64 -0
- data/spec/support/test_database.rb +1 -0
- data/vendor/assets/javascripts/highcharts.js +285 -0
- metadata +317 -62
- data/app/helpers/prosperity/metrics_helper.rb +0 -11
- data/app/views/layouts/prosperity/application.html.haml +0 -37
- data/app/views/prosperity/metrics/index.html.haml +0 -7
- data/db/migrate/20131026214127_test.rb +0 -4
- data/lib/prosperity/extractors/count.rb +0 -18
- data/lib/prosperity/extractors/group.rb +0 -23
- data/spec/lib/prosperity/extractors/count_spec.rb +0 -35
- data/spec/lib/prosperity/extractors/group_spec.rb +0 -34
- data/vendor/assets/javascripts/chart.js +0 -1426
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05c4975bfb8d25cc3a99a70c519d741a20409030
|
4
|
+
data.tar.gz: 409c4ec232d033c74e29a07d067154a0fbc40054
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05440b2f94e46093d8737b05649c18a0b62679cdf0464306d0693eabb48b1da7bdacaaf2a1419350c0c278032a6a2d3c95d3a45c4eb4007152a693270c20c55b
|
7
|
+
data.tar.gz: c2a87e6014004fbcb9b7982be91a60c7fa5f9e4709496de1e8b2c883e5a3911727da0dd2d6934f01e9ffadc9d970349b7e9607c6cb6403a4f4e55c1d3641526d
|
@@ -12,31 +12,12 @@
|
|
12
12
|
#
|
13
13
|
#= require jquery
|
14
14
|
#= require jquery_ujs
|
15
|
-
#= require
|
16
|
-
#= require twitter/bootstrap
|
15
|
+
#= require highcharts
|
17
16
|
#= require_tree .
|
18
17
|
|
19
18
|
$ ->
|
20
|
-
$("
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
datasets = []
|
25
|
-
|
26
|
-
size = 0
|
27
|
-
for key, data of points
|
28
|
-
datasets.push
|
29
|
-
data: data
|
30
|
-
fillColor : "rgba(151,187,205,0)",
|
31
|
-
strokeColor : "rgba(0,0,0,1)",
|
32
|
-
|
33
|
-
|
34
|
-
size = Math.max(size, data.length)
|
35
|
-
|
36
|
-
data =
|
37
|
-
labels : (i for i in [0..size])
|
38
|
-
datasets: datasets
|
39
|
-
|
40
|
-
myNewChart = new Chart(ctx).Line(data)
|
41
|
-
|
19
|
+
$(".metric").each (i, el) ->
|
20
|
+
$el = $(el)
|
21
|
+
url = $el.data('url')
|
22
|
+
graph = new Prosperity.Graph(el: el, url: url).render()
|
42
23
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Place all the behaviors and hooks related to the matching controller here.
|
2
|
+
# All this logic will automatically be available in application.js.
|
3
|
+
|
4
|
+
$(".link-graph").submit (e) ->
|
5
|
+
$form = $(e.target)
|
6
|
+
dashboard_id = $form.find("#dashboard_id").val()
|
7
|
+
graph_id = $form.find("#graph_id").val()
|
8
|
+
url_template = $form.find("#url_template").val()
|
9
|
+
|
10
|
+
url = url_template.replace("dashboard_id", dashboard_id)
|
11
|
+
url = url.replace("graph_id", graph_id)
|
12
|
+
#"/dashboards/#{dashboard_id}/graphs/#{graph_id}"
|
13
|
+
if $form.attr('action') != url
|
14
|
+
e.preventDefault()
|
15
|
+
$form.attr('action', url)
|
16
|
+
$form.submit()
|
17
|
+
|
@@ -0,0 +1,89 @@
|
|
1
|
+
|
2
|
+
class Graph
|
3
|
+
constructor: (option) ->
|
4
|
+
@url = option.url
|
5
|
+
@el = option.el
|
6
|
+
@$el = $(option.el)
|
7
|
+
|
8
|
+
render: ->
|
9
|
+
highchartsOptions =
|
10
|
+
chart:
|
11
|
+
type: 'line'
|
12
|
+
renderTo: @el
|
13
|
+
tooltip:
|
14
|
+
crosshairs: [true, true]
|
15
|
+
series: []
|
16
|
+
xAxis:
|
17
|
+
type: 'datetime'
|
18
|
+
dateTimeLabelFormats:
|
19
|
+
day: '%e of %b'
|
20
|
+
yAxis: [{}, {}, {}]
|
21
|
+
title:
|
22
|
+
text: "Loading..."
|
23
|
+
|
24
|
+
chart = new Highcharts.Chart(highchartsOptions)
|
25
|
+
|
26
|
+
getSeries = (url, axisIndex) =>
|
27
|
+
$.get url, (json) =>
|
28
|
+
axisIndex = Math.min(axisIndex, chart.yAxis.length - 1)
|
29
|
+
serie =
|
30
|
+
data: json.data
|
31
|
+
name: json.label
|
32
|
+
yAxis: axisIndex
|
33
|
+
pointStart: Date.parse(json.start_time)
|
34
|
+
pointInterval: json.period_milliseconds
|
35
|
+
|
36
|
+
axisSettings =
|
37
|
+
title: {text: json.key}
|
38
|
+
min: Math.min.apply(Math, json.data)
|
39
|
+
max: Math.max.apply(Math, json.data)
|
40
|
+
|
41
|
+
|
42
|
+
if json.key == 'change'
|
43
|
+
axisSettings = $.extend axisSettings, {
|
44
|
+
min: 0,
|
45
|
+
max: Math.max.apply(Math, json.data),
|
46
|
+
labels: {formatter: -> this.value + '%' },
|
47
|
+
opposite: true
|
48
|
+
}
|
49
|
+
|
50
|
+
serie = $.extend serie, {
|
51
|
+
tooltip: {valueDecimals: 2, valueSuffix: '%'}
|
52
|
+
}
|
53
|
+
|
54
|
+
chart.yAxis[axisIndex].update(axisSettings)
|
55
|
+
chart.addSeries(serie)
|
56
|
+
|
57
|
+
$.getJSON @url, (json) ->
|
58
|
+
chart.setTitle {text: json.title}
|
59
|
+
|
60
|
+
for extractor, index in json.extractors
|
61
|
+
getSeries(extractor.url, index)
|
62
|
+
|
63
|
+
@
|
64
|
+
|
65
|
+
@Prosperity ||= {}
|
66
|
+
@Prosperity.Graph = Graph
|
67
|
+
|
68
|
+
updateMetricOptions = (el) ->
|
69
|
+
$el = $(el)
|
70
|
+
return if $el.length == 0
|
71
|
+
$form = $el.parents('form')
|
72
|
+
options = $form.data('metric-options')
|
73
|
+
possibleOptions = options[$el.val()] || []
|
74
|
+
|
75
|
+
$optionSelect = $el.parents(".graph-line").find(".metric-option-select select")
|
76
|
+
selectedOption = $form.find("input[type=\"hidden\"][name=\"#{$optionSelect.attr('name')}\"]").val()
|
77
|
+
|
78
|
+
$optionSelect.html('')
|
79
|
+
for option in possibleOptions
|
80
|
+
$optionSelect.append $('<option>', value: option, text: option, selected: selectedOption == option)
|
81
|
+
|
82
|
+
$(document).on "change", ".edit_graph .metric-title-select select", (e) ->
|
83
|
+
updateMetricOptions e.target
|
84
|
+
|
85
|
+
$ ->
|
86
|
+
$(".edit_graph .metric-title-select select").each (i, el) ->
|
87
|
+
updateMetricOptions el
|
88
|
+
|
89
|
+
|
@@ -1,4 +1,34 @@
|
|
1
1
|
module Prosperity
|
2
2
|
class ApplicationController < ActionController::Base
|
3
|
+
protected
|
4
|
+
def set_error(model)
|
5
|
+
flash[:error] = model.errors.full_messages.to_sentence
|
6
|
+
end
|
7
|
+
|
8
|
+
def render_json_error(msg, code)
|
9
|
+
render json: {error: msg}, status: code
|
10
|
+
end
|
11
|
+
|
12
|
+
def strong_params?
|
13
|
+
defined?(ActionController::StrongParameters)
|
14
|
+
end
|
15
|
+
|
16
|
+
def now
|
17
|
+
@now ||= Time.now
|
18
|
+
end
|
19
|
+
|
20
|
+
def period
|
21
|
+
params.fetch(:period, 'week')
|
22
|
+
end
|
23
|
+
|
24
|
+
def end_time
|
25
|
+
params[:end_time].present? ? Time.parse(params[:end_time].to_s) : now
|
26
|
+
end
|
27
|
+
|
28
|
+
def start_time
|
29
|
+
params[:start_time].present? ? Time.parse(params[:start_time].to_s) : end_time - 3.months
|
30
|
+
end
|
31
|
+
|
32
|
+
helper_method :end_time, :start_time, :period
|
3
33
|
end
|
4
34
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_dependency "prosperity/application_controller"
|
2
|
+
|
3
|
+
module Prosperity
|
4
|
+
class DashboardGraphsController < ApplicationController
|
5
|
+
before_action :get_objs
|
6
|
+
def create
|
7
|
+
DashboardGraph.create!(graph: @graph, dashboard: @dashboard)
|
8
|
+
redirect_to edit_dashboard_path(@dashboard)
|
9
|
+
end
|
10
|
+
|
11
|
+
def destroy
|
12
|
+
dashboard_graph = DashboardGraph.where(graph_id: @graph.id, dashboard_id: @dashboard.id).first
|
13
|
+
raise ActiveRecord::RecordNotFound unless dashboard_graph
|
14
|
+
dashboard_graph.destroy
|
15
|
+
redirect_to edit_dashboard_path(@dashboard)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def get_objs
|
20
|
+
@graph = Graph.find(params[:graph_id])
|
21
|
+
@dashboard = Dashboard.find(params[:dashboard_id])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_dependency "prosperity/application_controller"
|
2
|
+
|
3
|
+
module Prosperity
|
4
|
+
class DashboardsController < ApplicationController
|
5
|
+
def index
|
6
|
+
@dashboards = Dashboard.all
|
7
|
+
end
|
8
|
+
|
9
|
+
def new
|
10
|
+
@dashboard = Dashboard.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def show
|
14
|
+
@dashboard = Dashboard.find(params[:id])
|
15
|
+
end
|
16
|
+
|
17
|
+
def edit
|
18
|
+
@dashboard = Dashboard.find(params[:id])
|
19
|
+
end
|
20
|
+
|
21
|
+
def create
|
22
|
+
@dashboard = Dashboard.new
|
23
|
+
@dashboard.title = params.fetch(:dashboard, {})[:title]
|
24
|
+
@dashboard.default = false
|
25
|
+
if @dashboard.save
|
26
|
+
redirect_to action: :index
|
27
|
+
else
|
28
|
+
flash[:error] = @dashboard.errors.full_messages.to_sentence
|
29
|
+
render action: :new
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require_dependency "prosperity/application_controller"
|
2
|
+
|
3
|
+
module Prosperity
|
4
|
+
class GraphsController < ApplicationController
|
5
|
+
before_action :get_graph, only: [:edit, :update, :show]
|
6
|
+
def new
|
7
|
+
@graph = Graph.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def edit
|
11
|
+
@metrics = MetricFinder.all.map(&:new)
|
12
|
+
@options = @metrics.inject({}) do |h, metric|
|
13
|
+
h[metric.id] = metric.options.keys
|
14
|
+
h
|
15
|
+
end
|
16
|
+
@graph.graph_lines.build
|
17
|
+
end
|
18
|
+
|
19
|
+
def show
|
20
|
+
render json: {
|
21
|
+
title: @graph.title,
|
22
|
+
extractors: @graph.graph_lines.map do |line|
|
23
|
+
{
|
24
|
+
key: line.extractor,
|
25
|
+
url: data_metric_path(id: line.metric,
|
26
|
+
extractor: line.extractor,
|
27
|
+
option: line.option,
|
28
|
+
period: @graph.period,
|
29
|
+
start_time: start_time,
|
30
|
+
end_time: end_time),
|
31
|
+
}
|
32
|
+
end
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def update
|
37
|
+
unless @graph.update_attributes(graph_params)
|
38
|
+
set_error(@graph)
|
39
|
+
end
|
40
|
+
redirect_to action: :edit
|
41
|
+
end
|
42
|
+
|
43
|
+
def create
|
44
|
+
@graph = Graph.new
|
45
|
+
[:title, :period].each do |attr|
|
46
|
+
@graph.send("#{attr}=", graph_params[attr])
|
47
|
+
end
|
48
|
+
|
49
|
+
if @graph.save
|
50
|
+
redirect_to edit_graph_path(@graph)
|
51
|
+
else
|
52
|
+
set_error(@graph)
|
53
|
+
render action: :new
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def get_graph
|
60
|
+
@graph = Graph.find(params[:id])
|
61
|
+
end
|
62
|
+
|
63
|
+
def graph_params
|
64
|
+
if strong_params?
|
65
|
+
params.require(:graph).
|
66
|
+
permit(Graph::ATTR_ACCESSIBLE + [:graph_lines_attributes => (GraphLine::ATTR_ACCESSIBLE + [:id])])
|
67
|
+
else
|
68
|
+
params.fetch(:graph, {})
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -2,8 +2,65 @@ require_dependency "prosperity/application_controller"
|
|
2
2
|
|
3
3
|
module Prosperity
|
4
4
|
class MetricsController < ApplicationController
|
5
|
+
before_filter :get_metric, only: [:show, :data]
|
6
|
+
|
5
7
|
def index
|
6
8
|
@metrics = MetricFinder.all
|
7
9
|
end
|
10
|
+
|
11
|
+
def show
|
12
|
+
respond_to do |format|
|
13
|
+
format.html
|
14
|
+
format.json do
|
15
|
+
render json: {
|
16
|
+
id: @metric.id,
|
17
|
+
title: @metric.title,
|
18
|
+
options: @metric.options.map do |k, option|
|
19
|
+
{key: k}
|
20
|
+
end,
|
21
|
+
extractors: @metric.extractors.map do |ext|
|
22
|
+
{
|
23
|
+
key: ext.key,
|
24
|
+
url: data_metric_path(id: @metric.id,
|
25
|
+
extractor: ext.key,
|
26
|
+
option: option,
|
27
|
+
period: period,
|
28
|
+
start_time: start_time,
|
29
|
+
end_time: end_time),
|
30
|
+
|
31
|
+
}
|
32
|
+
end
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def data
|
39
|
+
ext_klass = Metric.extractors[params.fetch(:extractor, "interval")]
|
40
|
+
|
41
|
+
p = Prosperity::Periods::ALL.fetch(period)
|
42
|
+
ext = ext_klass.new(@metric, option, start_time, end_time, p)
|
43
|
+
|
44
|
+
json = {
|
45
|
+
data: ext.to_a,
|
46
|
+
key: ext.key,
|
47
|
+
label: ext.label,
|
48
|
+
start_time: start_time.iso8601,
|
49
|
+
period_milliseconds: p.duration * 1000
|
50
|
+
}
|
51
|
+
render json: json
|
52
|
+
end
|
53
|
+
private
|
54
|
+
|
55
|
+
def get_metric
|
56
|
+
@metric = MetricFinder.find_by_name(params.fetch(:id)).new
|
57
|
+
rescue NameError
|
58
|
+
render_json_error("Could not find metric #{params.fetch(:id)}", 404)
|
59
|
+
end
|
60
|
+
|
61
|
+
def option
|
62
|
+
params.fetch(:option, 'default')
|
63
|
+
end
|
64
|
+
helper_method :option
|
8
65
|
end
|
9
66
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Prosperity
|
2
|
+
class Graph < ActiveRecord::Base
|
3
|
+
has_many :graph_lines, class_name: 'Prosperity::GraphLine'
|
4
|
+
validates_presence_of :title, :period
|
5
|
+
accepts_nested_attributes_for :graph_lines, reject_if: :not_filled?
|
6
|
+
|
7
|
+
ATTR_ACCESSIBLE = [:title, :period, :graph_lines].freeze
|
8
|
+
|
9
|
+
attr_accessible *ATTR_ACCESSIBLE unless defined?(ActionController::StrongParameters)
|
10
|
+
|
11
|
+
private
|
12
|
+
def not_filled?(line)
|
13
|
+
if line[:id]
|
14
|
+
false
|
15
|
+
else
|
16
|
+
line[:option].blank? || line[:metric].blank?
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>(lang="en")
|
3
|
+
<head>
|
4
|
+
<title>
|
5
|
+
<%= content_for?(:title) ? yield(:title) : app_name %>
|
6
|
+
</title>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
<!-- Le HTML5 shim, for IE6-8 support of HTML elements
|
9
|
+
-->
|
10
|
+
<!--[if lt IE 9]
|
11
|
+
<%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.1/html5shiv.js" %>
|
12
|
+
-->
|
13
|
+
<%= stylesheet_link_tag "prosperity/application", :media => "all" %>
|
14
|
+
</head>
|
15
|
+
<body>
|
16
|
+
<div class="navbar navbar-inverse navbar-fixed-top">
|
17
|
+
<div class="container">
|
18
|
+
<div class="navbar-header">
|
19
|
+
<button class="navbar-toggle" data-target=".navbar-collapse" data-toggle="collapse" type="button">
|
20
|
+
<span class="icon-bar"></span>
|
21
|
+
<span class="icon-bar"></span>
|
22
|
+
<span class="icon-bar"></span>
|
23
|
+
</button>
|
24
|
+
<a class="navbar-brand" href="<%= root_path %>">
|
25
|
+
<%= app_name %>
|
26
|
+
</a>
|
27
|
+
</div>
|
28
|
+
<div class="collapse navbar-collapse">
|
29
|
+
<ul class="nav navbar-nav">
|
30
|
+
<li class="active">
|
31
|
+
<a href="<%= dashboards_path %>">Dashboards</a>
|
32
|
+
</li>
|
33
|
+
<li>
|
34
|
+
<a href="<%= metrics_path %>">All Metrics</a>
|
35
|
+
</li>
|
36
|
+
</ul>
|
37
|
+
</div>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
<div class="container">
|
41
|
+
<div class="main">
|
42
|
+
<% flash.each do |name, msg| %>
|
43
|
+
<% if msg.is_a?(String) %>
|
44
|
+
<div class="alert alert-<%= name == :notice ? "success" : "error" %>">
|
45
|
+
<a class="close" data-dismiss="alert">×</a>
|
46
|
+
<%= content_tag :div, msg, :id => "flash_#{name}" %>
|
47
|
+
</div>
|
48
|
+
<% end %>
|
49
|
+
<% end %>
|
50
|
+
|
51
|
+
<%= yield %>
|
52
|
+
</div>
|
53
|
+
</div>
|
54
|
+
<%= javascript_include_tag "prosperity/application" %>
|
55
|
+
</body>
|
56
|
+
</html>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<h1>Edit Dashboard</h1>
|
2
|
+
|
3
|
+
<% if Prosperity::Graph.exists? %>
|
4
|
+
<ul>
|
5
|
+
<% @dashboard.graphs.each do |graph| %>
|
6
|
+
<li>
|
7
|
+
<%= link_to graph.title, edit_graph_path(graph) %>
|
8
|
+
-
|
9
|
+
<%= link_to 'Delete', dashboard_dashboard_graphs_path(dashboard_id: @dashboard.id, graph_id: graph.id), method: :delete %>
|
10
|
+
</li>
|
11
|
+
<% end %>
|
12
|
+
</ul>
|
13
|
+
|
14
|
+
<%= form_tag({}, class: "link-graph", method: "POST") do %>
|
15
|
+
<%= hidden_field_tag :dashboard_id, @dashboard.id %>
|
16
|
+
<%= hidden_field_tag :url_template, dashboard_dashboard_graphs_path(dashboard_id: 'dashboard_id', graph_id: 'graph_id') %>
|
17
|
+
<%= select_tag :graph_id, options_from_collection_for_select(Prosperity::Graph.all, :id, :title) %>
|
18
|
+
<%= submit_tag "Add To Dashboard", class: 'btn btn-success' %>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
OR
|
22
|
+
<% end %>
|
23
|
+
|
24
|
+
<%= link_to "Add New Graph", new_graph_path, class: 'btn btn-primary' %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<h1>Dashboards</h1>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<ul>
|
5
|
+
<% for dashboard in @dashboards %>
|
6
|
+
<li>
|
7
|
+
<%= link_to dashboard.title, dashboard_path(dashboard) %>
|
8
|
+
-
|
9
|
+
<%= link_to 'edit', edit_dashboard_path(dashboard) %>
|
10
|
+
</li>
|
11
|
+
<% end %>
|
12
|
+
</ul>
|
13
|
+
</p>
|
14
|
+
|
15
|
+
<a href="<%= new_dashboard_path %>" class="btn btn-primary">New Dashboard</a>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<h1><%= @dashboard.title %></h1>
|
2
|
+
|
3
|
+
<%= form_tag(dashboard_path(params[:id]), method: 'get') do %>
|
4
|
+
<%= render 'prosperity/shared/date_range' %>
|
5
|
+
<%= submit_tag "Update", class: 'btn btn-primary' %>
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
<% @dashboard.graphs.each do |graph| %>
|
9
|
+
<div class="graph">
|
10
|
+
<h2><%= graph.title %></h2>
|
11
|
+
|
12
|
+
<div class="metric" data-url="<%= graph_path(graph, start_time: start_time) %>"></div>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<h1>Edit Graph</h1>
|
2
|
+
|
3
|
+
<p>Title: <%= @graph.title%></p>
|
4
|
+
|
5
|
+
<div class="row">
|
6
|
+
<div class="span6">
|
7
|
+
<%= form_for @graph, data: {metric_options: @options} do |f| %>
|
8
|
+
<h4>Lines</h4>
|
9
|
+
<%= f.fields_for :graph_lines do |l| %>
|
10
|
+
<% if l.object.new_record? %>
|
11
|
+
<h4>Add New Line</h4>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="graph-line">
|
15
|
+
<div class="form-group metric-title-select">
|
16
|
+
<%= l.label :metric %>
|
17
|
+
<%= l.select :metric, @metrics.map{|m| [m.title, m.id]}, include_blank: true %>
|
18
|
+
</div>
|
19
|
+
|
20
|
+
<div class="form-group metric-option-select">
|
21
|
+
<%= l.hidden_field :option %>
|
22
|
+
<%= l.label :option %>
|
23
|
+
<%= l.select :option, [] %>
|
24
|
+
</div>
|
25
|
+
|
26
|
+
<div class="form-group">
|
27
|
+
<%= l.label :extractor %>
|
28
|
+
<%= l.select :extractor, options_for_extractors %>
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
<% end %>
|
32
|
+
<%= f.submit "Save & View", class: "btn btn-success" %>
|
33
|
+
<% end %>
|
34
|
+
</div>
|
35
|
+
|
36
|
+
<div class="span8">
|
37
|
+
<div class="graph well"/>
|
38
|
+
<div class="metric" data-url="<%= graph_path(@graph) %>"></div>
|
39
|
+
</div>
|
40
|
+
</div>
|
41
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<h1>New Graph</h1>
|
2
|
+
|
3
|
+
<%= form_for @graph, html: {role: 'form'} do |f| %>
|
4
|
+
<div class="form-group">
|
5
|
+
<%= f.label :title %>
|
6
|
+
<%= f.text_field :title %>
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<div class="form-group">
|
10
|
+
<%= f.label :period %>
|
11
|
+
<%= f.select :period, Prosperity::Periods::ALL.keys %>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<%= f.submit "Save", class: 'btn btn-success' %>
|
15
|
+
<% end %>
|