quick_search-core 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -6
  3. data/app/assets/javascripts/quick_search.js.erb +9 -0
  4. data/app/assets/javascripts/quick_search/appstats.js.erb +73 -0
  5. data/app/assets/javascripts/quick_search/appstats_best_bets.js.erb +905 -0
  6. data/app/assets/javascripts/quick_search/appstats_clicks_overview.js.erb +719 -0
  7. data/app/assets/javascripts/quick_search/appstats_general_statistics.js.erb +908 -0
  8. data/app/assets/javascripts/quick_search/appstats_sessions_details.js.erb +660 -0
  9. data/app/assets/javascripts/quick_search/appstats_sessions_overview.js.erb +481 -0
  10. data/app/assets/javascripts/quick_search/appstats_spelling_suggestions.js.erb +902 -0
  11. data/app/assets/javascripts/quick_search/appstats_top_searches.js.erb +633 -0
  12. data/app/assets/javascripts/quick_search/event_tracking.js.erb +22 -33
  13. data/app/assets/javascripts/quick_search/xhr_search.js +7 -3
  14. data/app/assets/stylesheets/quick_search/appstats.scss +148 -0
  15. data/app/assets/stylesheets/quick_search/quick_search.scss +0 -16
  16. data/app/controllers/concerns/quick_search/doi_trap.rb +1 -1
  17. data/app/controllers/quick_search/appstats_controller.rb +267 -144
  18. data/app/controllers/quick_search/logging_controller.rb +165 -0
  19. data/app/controllers/quick_search/search_controller.rb +1 -23
  20. data/app/controllers/quick_search/typeahead_controller.rb +48 -0
  21. data/app/models/event.rb +6 -0
  22. data/app/models/search.rb +7 -0
  23. data/app/models/session.rb +9 -0
  24. data/app/searchers/quick_search/best_bets_searcher.rb +1 -1
  25. data/app/views/layouts/quick_search/_google_analytics.html.erb +4 -9
  26. data/app/views/layouts/quick_search/_search_form.html.erb +2 -2
  27. data/app/views/layouts/quick_search/application.html.erb +4 -0
  28. data/app/views/quick_search/appstats/_date_range.html.erb +14 -13
  29. data/app/views/quick_search/appstats/_graph_best_bets.html.erb +6 -0
  30. data/app/views/quick_search/appstats/_graph_clicks_overview.html.erb +12 -0
  31. data/app/views/quick_search/appstats/_graph_general_statistics.html.erb +19 -0
  32. data/app/views/quick_search/appstats/_graph_sessions_details.html.erb +19 -0
  33. data/app/views/quick_search/appstats/_graph_sessions_overview.html.erb +9 -0
  34. data/app/views/quick_search/appstats/_graph_spelling_suggestions.html.erb +6 -0
  35. data/app/views/quick_search/appstats/_graph_top_searches.html.erb +6 -0
  36. data/app/views/quick_search/appstats/_menu.html.erb +16 -3
  37. data/app/views/quick_search/appstats/_sessions_details_device_filters.html.erb +9 -0
  38. data/app/views/quick_search/appstats/_sessions_details_location_filters.html.erb +9 -0
  39. data/app/views/quick_search/appstats/_sessions_overview_graph_filters.html.erb +9 -0
  40. data/app/views/quick_search/appstats/clicks_overview.html.erb +3 -14
  41. data/app/views/quick_search/appstats/index.html.erb +3 -23
  42. data/app/views/quick_search/appstats/sessions_details.html.erb +9 -0
  43. data/app/views/quick_search/appstats/sessions_overview.html.erb +9 -0
  44. data/app/views/quick_search/appstats/top_searches.html.erb +3 -32
  45. data/app/views/quick_search/appstats/top_spot.html.erb +7 -7
  46. data/app/views/quick_search/search/_module_with_paging.html.erb +1 -1
  47. data/app/views/quick_search/search/_result_title.html.erb +1 -1
  48. data/config/quicksearch_config.yml.example +3 -0
  49. data/config/routes.rb +31 -3
  50. data/db/migrate/20161201141003_create_sessions.rb +12 -0
  51. data/db/migrate/20161201142811_change_event_columns.rb +11 -0
  52. data/db/migrate/20161201143901_add_session_id_to_searches.rb +5 -0
  53. data/db/migrate/20161212192454_add_date_string_columns.rb +11 -0
  54. data/db/seeds.rb +83 -7
  55. data/lib/generators/quick_search/templates/quick_search_typeahead.js +253 -0
  56. data/lib/generators/quick_search/typeahead_generator.rb +162 -0
  57. data/lib/quick_search/engine.rb +1 -0
  58. data/lib/quick_search/version.rb +1 -1
  59. data/test/dummy/db/schema.rb +25 -6
  60. data/test/dummy/log/benchmark.log +121 -241
  61. data/test/dummy/log/development.log +236 -0
  62. data/test/dummy/tmp/cache/assets/sprockets/v3.0/0b/0bXp2nnjPLNuYQRAMo1RkhNr8RSC8vqZo_7soo0XZTE.cache +1 -0
  63. data/test/dummy/tmp/cache/assets/sprockets/v3.0/3p/3pAfj3gt9c9rLmOrDkMvW2r6Swm5YhuGQ1EN3va9LDE.cache +6 -0
  64. data/test/dummy/tmp/cache/assets/sprockets/v3.0/3r/3r7qg-LCIcD5882b6GKgRTZycpAlhoSNJccVH06yRCQ.cache +3 -0
  65. data/test/dummy/tmp/cache/assets/sprockets/v3.0/{UA/UAOIipK_ejTAUFI6XxASoweyUiC3t64VfVzV-MfsFD8.cache → 4h/4hLiHzJdffGLMZCeIkbisOdFQSyqs54YkoZpBpGotVk.cache} +0 -0
  66. data/test/dummy/tmp/cache/assets/sprockets/v3.0/{Hr/Hr-kCuPY72nIKAdnsDTz9JqXd_z1WL6FSGMAq4HppZg.cache → 5Y/5Yh8GnSzywqhuMWMloKnL9FnuIxa9rBw6hN2Ecv0urw.cache} +0 -0
  67. data/test/dummy/tmp/cache/assets/sprockets/v3.0/8h/8hHsBZ0Il3GVKNj0HgTh-s-XpPVkHrcSY0EJ4v548sk.cache +4 -0
  68. data/test/dummy/tmp/cache/assets/sprockets/v3.0/{fI/fInu_Gja7ik39t207tqj4CtlL0akQRbjD2T7qEtd0zE.cache → 8n/8nKAboU_CeVIX30-Q9BtSV5TXdE07WU8hO0OQ0N3KOs.cache} +0 -0
  69. data/test/dummy/tmp/cache/assets/sprockets/v3.0/{dz/dzCaa80YgyvJINTgsyrVhKv9UQ1OC82GfAsA-IP96iQ.cache → Af/Afug8duevWkZFPkOMnZ5z_IbRT6JMZo4jw1QFmLiXXA.cache} +0 -0
  70. data/test/dummy/tmp/cache/assets/sprockets/v3.0/C2/C24SLDoUbdiHRmPZx5lIZ3XPXmn9FDq7j7gZmbpDtcE.cache +1 -0
  71. data/test/dummy/tmp/cache/assets/sprockets/v3.0/CH/CHuDjj47dHGqRD3uN1JNwnlFyjjEKB09KR6WVsLj2Do.cache +3 -0
  72. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Ci/Cif3NOwhu5i6Qm3iRv2gNJLi_cu8yDVz0Nrq8TZu1tc.cache +3 -0
  73. data/test/dummy/tmp/cache/assets/sprockets/v3.0/FQ/FQWd8V-Pek1LBAfW9vzcG-FpWySsPRhMVzH9DlPxLWU.cache +1 -0
  74. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Fa/FaYEz8CfLTkxVZvnbgKGvJMhhBwNvEgsZgUwaHNRlaQ.cache +0 -0
  75. data/test/dummy/tmp/cache/assets/sprockets/v3.0/IA/IALQq6ICbs3VBSRsaUmGuN73Qv5wDfWTP86VmMh_sVs.cache +0 -0
  76. data/test/dummy/tmp/cache/assets/sprockets/v3.0/K1/K1jnTrW-_s64kqCA6fnoQ-ID-rDaGX34J-TNPyzDbLs.cache +1 -0
  77. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Mz/MzXE1Go_GKyu6AvJPhw394BtPM_jVTf0hMwobBi15tk.cache +1 -0
  78. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Os/OsIhoBDw5N2AWGQ-EMK79tgwPS1AC6Dy_gMSJdOv2Ss.cache +0 -0
  79. data/test/dummy/tmp/cache/assets/sprockets/v3.0/{B5/B5ptGSZGmgHvoK2UDCAtpMhWxJEKxKFhyL9ACeBfzQk.cache → PC/PCth9nzoRrp5GI3Ut8FxlGpXjH63V7k2p4PRwfyu2sQ.cache} +0 -0
  80. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Pw/Pw3Jv2p7MsQz6pttCZig6VMVQ30sRyIDRS-2nM32yqY.cache +3 -0
  81. data/test/dummy/tmp/cache/assets/sprockets/v3.0/RI/RIOgtcuvLAJZl62RvAzqine3jCO3i2qyhswiW2G1bw8.cache +3 -0
  82. data/test/dummy/tmp/cache/assets/sprockets/v3.0/R_/R_6WhfFaPUAOAFfFd4bgUonI5aB4Fa6iOMY2J6G3U98.cache +4 -0
  83. data/test/dummy/tmp/cache/assets/sprockets/v3.0/{pj/pjJDYrBipDo6Tr9_-W4UDzfZZ4UPTy9YpXrBQFRXnlo.cache → S3/S3gPdA-Zqya5r6wNhnlwqGV3B3-GDaA8i1fL_jo66AI.cache} +0 -0
  84. data/test/dummy/tmp/cache/assets/sprockets/v3.0/SS/SS3eYrFE6ghi5G_3POW760Y4BWo5OAaK5QjDrRGXOcs.cache +1 -0
  85. data/test/dummy/tmp/cache/assets/sprockets/v3.0/{jj/jjdQCKZsewws2eRP7b2AVxRMvseOp8djjlDkB8UOtac.cache → Sq/SqjdxmYsdurpx9xk1ks32WEtf3D9_2BysE7RMxnOlmU.cache} +1 -1
  86. data/test/dummy/tmp/cache/assets/sprockets/v3.0/{os/os0qWv3yDfep0e7vVSGTgfn_n3xc4C4QZgmMzLQn0Ks.cache → Ta/TaJnQ_l0sfSsDOyVoi-S-KZQ6vIwzBhmS6hmNA_n8ug.cache} +0 -0
  87. data/test/dummy/tmp/cache/assets/sprockets/v3.0/{o6/o6ZQbq1aBFuVrE2xLbSbyZH2736sWM3Yj4ky9chT1bI.cache → X_/X_CxFXEdZo2C_in7FopAuAbplHn6W_V0SXyVQAMnTzI.cache} +0 -0
  88. data/test/dummy/tmp/cache/assets/sprockets/v3.0/{sR/sRU-UT8qK_38kkiFDXKBPogO1oOZuSvJFH-pgqPL_Ms.cache → Yh/YhRWll6bzgYE6Dmc5fVKbHyv5om4y3-27UrWeUbQcGk.cache} +0 -0
  89. data/test/dummy/tmp/cache/assets/sprockets/v3.0/{OD/ODHapE0li3WI1laVJoksoI5nmQd-8dDJXq_VxS4XefE.cache → _u/_uiA10I5HyJR94Tbc4a06CzdrQCAXX7Iz86WS5PKDQo.cache} +0 -0
  90. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ai/ainCVF4dxXf85KoOLUSHvMMGg0qBNc7Vg-s-9v2ENJI.cache +4 -0
  91. data/test/dummy/tmp/cache/assets/sprockets/v3.0/cQ/cQqt0ri9GFvVnIs1pJUugIJs5tDuGQMMntW5CwpK6YY.cache +1 -0
  92. data/test/dummy/tmp/cache/assets/sprockets/v3.0/{1n/1nStVaWIQEwAlksUpB1fInwq6v3TikPvuRaSwwCnCLQ.cache → e0/e0Y2Gz8ftaW2O0RjoN2iWguitI-JQZckScAZqlQYkng.cache} +0 -0
  93. data/test/dummy/tmp/cache/assets/sprockets/v3.0/iH/iHnlNNY3rfdbVqt8LZBfcDQYONR8dA8LmxA9fv5paro.cache +2 -0
  94. data/test/dummy/tmp/cache/assets/sprockets/v3.0/{F0/F0oWBwLHpGFYNNtnGav-dJFH8rMDpNA5L8_aWm5Wq34.cache → ir/irxgIDPIY6Wz6fHWYp1dIrqAT1_8oa6-oiwqbFE_e-w.cache} +0 -0
  95. data/test/dummy/tmp/cache/assets/sprockets/v3.0/kn/knUtyVrg7nMIPldZa4MHhe7cC9eMchLZS4mc5HDWgDY.cache +1 -0
  96. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ks/ks4DoIuUV6oUzoiXoPh7sW1k5ExNoUkR7ICjwuRnAT0.cache +1 -0
  97. data/test/dummy/tmp/cache/assets/sprockets/v3.0/m3/m375QQakjXd_2Trpvdot-i90nmeCCh0HWtzS66ZvxUU.cache +1 -0
  98. data/test/dummy/tmp/cache/assets/sprockets/v3.0/rQ/rQ_FgYkT2hdw9A6XmJKGgVb2dMtCrWWHwtS0X1_kdl0.cache +1 -0
  99. data/test/dummy/tmp/cache/assets/sprockets/v3.0/{pw/pwiIhcWPwTuy5Miz5zqOQGYFx-K3TbaCVQ6ls7EBkk0.cache → rU/rUqFWwHqrT5jeIFCEezOPsMMZiAU7ri6RKBGS2ezAfg.cache} +0 -0
  100. data/test/dummy/tmp/cache/assets/sprockets/v3.0/{pO/pO8hHVwybv1ZJBdPa2YC6bjqmk020OYFl85TYxtmrWQ.cache → rq/rqf5-J6k_zLc9ZlUgMj28nviKtRsko3-iEp_m_uNeY0.cache} +0 -0
  101. data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  102. data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  103. data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  104. data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  105. data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  106. data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  107. metadata +143 -119
  108. data/app/assets/javascripts/quick_search/appstats.js +0 -8
  109. data/app/views/quick_search/appstats/_click_count_table.html.erb +0 -23
  110. data/app/views/quick_search/appstats/_top_spot_report_table.html.erb +0 -33
  111. data/app/views/quick_search/appstats/module_click_detail.html.erb +0 -32
  112. data/app/views/quick_search/appstats/top_spot_detail.html.erb +0 -35
  113. data/test/dummy/tmp/cache/assets/sprockets/v3.0/0_/0_w_ydOOEFQOoETxJa-IxKppQocaiDwM5V08djCPYso.cache +0 -3
  114. data/test/dummy/tmp/cache/assets/sprockets/v3.0/3m/3mWfBeEpm_bJvaPQZYvnnAVtE_2helOWh_Tv-cEflrk.cache +0 -5
  115. data/test/dummy/tmp/cache/assets/sprockets/v3.0/4s/4sg52OgD5l4qx4GnojCVxg2itqwqb-KRanEdmdMus3Y.cache +0 -0
  116. data/test/dummy/tmp/cache/assets/sprockets/v3.0/5U/5UPnsccuZFLk9OqbmFMvB55mbvGptApx9Z55HWjEN90.cache +0 -3
  117. data/test/dummy/tmp/cache/assets/sprockets/v3.0/9a/9acKNgyVD8_WK401tMy6Ce98g-LS4VpwFvGQdzCV9mI.cache +0 -0
  118. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Ba/BaymviI8cwAJQMOIzWCf6Lt-PM2sNFTvY9hQKsfDNNw.cache +0 -3
  119. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Dd/DdFHg3C_voetfvKGKX7t8PGzZlkO45-huHNtaou5rxg.cache +0 -1
  120. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Fp/FprCQeeZguht46WNSpA3Y3JHKehovFXrj63nDrvvwFE.cache +0 -1
  121. data/test/dummy/tmp/cache/assets/sprockets/v3.0/GJ/GJrfWiarIi0Dt6sdKVMfUF1cdZ6NbqZxXHhzNbFtpBw.cache +0 -1
  122. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Gp/GpoziOxxB-hisco0rl7Nnsnw0UWud7R9Yge2Q3o1eN4.cache +0 -2
  123. data/test/dummy/tmp/cache/assets/sprockets/v3.0/It/It5VkJv-53-LICLKZWWyp2WcbD86DGotAL0MY3hhfpg.cache +0 -6
  124. data/test/dummy/tmp/cache/assets/sprockets/v3.0/O6/O6dw148Xya7NYlsRFMEzJyvRcySM6iOL1jRUpdQo9B8.cache +0 -1
  125. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Oj/OjMkKTW7OkthjJAQHDID8GV30IZC9F0dJ1zGiFame9U.cache +0 -4
  126. data/test/dummy/tmp/cache/assets/sprockets/v3.0/SU/SUtZ_ltPqy9A9A-_zqNPhNPvjxCOnrdqXHSZv5S9mOk.cache +0 -1
  127. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Tv/TvZgmm69VEMHUJQIBoij61oXMkgzp6whVo7l8mJ9qpw.cache +0 -3
  128. data/test/dummy/tmp/cache/assets/sprockets/v3.0/YJ/YJZdK01T1KTS84Mb6p_2TasmJNZeGZc4FMtBPCKGr_M.cache +0 -3
  129. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ah/ahhhd3ysbQmVDNzq2L_rb4t6rqqdnqeY6ujztBoZDA8.cache +0 -1
  130. data/test/dummy/tmp/cache/assets/sprockets/v3.0/gv/gvZKkbgiExbcQrT4eo0HB-j4JoDRAxdmDjKRxeEdK0Y.cache +0 -1
  131. data/test/dummy/tmp/cache/assets/sprockets/v3.0/hj/hj_r-O1QjHJIPcZVnlB_FGPdIRAi9NkxpT2oXDRIsGE.cache +0 -1
  132. data/test/dummy/tmp/cache/assets/sprockets/v3.0/o2/o2V1ahk8vFR6sXWNh5BB7w6MBj04zCyX-o1xFZONydE.cache +0 -1
  133. data/test/dummy/tmp/cache/assets/sprockets/v3.0/tE/tEO71oPPFXN_2c4p39nU0OiF9ARg13fjdQlnPqAx1KY.cache +0 -4
  134. data/test/dummy/tmp/cache/assets/sprockets/v3.0/tW/tWFRsAv4WWu2ch-x3AJZd3KOvBXG3MwH6Q6Xn-tFBtw.cache +0 -1
  135. data/test/dummy/tmp/cache/assets/sprockets/v3.0/x6/x6W754ylumshr3wBUHHmcgyWs8UR3Od7FaI6tqvjKmk.cache +0 -1
  136. data/test/dummy/tmp/cache/assets/sprockets/v3.0/yy/yyJ1P7RQciOiW8TgQiu1RMDdbWd4rqxd2BGU9HkY3L8.cache +0 -0
@@ -0,0 +1,719 @@
1
+ <% url_helper = QuickSearch::Engine.routes.url_helpers %>
2
+
3
+ (function() {
4
+ var AppStatsGlobals = {};
5
+ AppStatsGlobals["#graph_module_clicks"] = {};
6
+ AppStatsGlobals["#graph_result_clicks"] = {};
7
+
8
+ $(document).on("turbolinks:load", function() {
9
+ if ($("#graph_module_clicks").length) {
10
+ d3.select("#moduleIconContainer").append("i")
11
+ .attr("class", "fa fa-spinner fa-spin fa-5x fa-fw big-icon")
12
+ .attr("id", "moduleIcon");
13
+ d3.select("#resultIconContainer").append("i")
14
+ .attr("class", "fa fa-spinner fa-spin fa-5x fa-fw big-icon")
15
+ .attr("id", "resultIcon");
16
+ // Redraw graph if the date range is changed
17
+ document.getElementById("dateButton").addEventListener("click", function() {
18
+ var from = $("#from").datepicker("getDate");
19
+ var to = new Date($("#to").datepicker("getDate").getTime() + 1000 * 60 * 60 * 24);
20
+ document.getElementById("numDays").innerHTML = "" + parseInt((to - from) / (1000 * 60 * 60 * 24));
21
+ $.ajax({
22
+ type: "GET",
23
+ contentType: "application/json; charset=utf-8",
24
+ url: '<%= url_helper.data_module_clicks_path %>',
25
+ dataType: "json",
26
+ data: {
27
+ "start_date": from,
28
+ "end_date": to
29
+ },
30
+ success: function(moduleDataSet) {
31
+ var moduleData = _.cloneDeep(moduleDataSet);
32
+ AppStatsGlobals["#graph_module_clicks"].OriginalData = moduleData;
33
+ AppStatsGlobals["#graph_module_clicks"].Data = moduleData;
34
+ sort_clicks_overview("#graph_module_clicks", AppStatsGlobals["#graph_module_clicks"].Sort);
35
+ },
36
+ error: function(result) {
37
+ error();
38
+ }
39
+ });
40
+ $.ajax({
41
+ type: "GET",
42
+ contentType: "application/json; charset=utf-8",
43
+ url: '<%= url_helper.data_result_clicks_path %>',
44
+ dataType: "json",
45
+ data: {
46
+ "start_date": from,
47
+ "end_date": to
48
+ },
49
+ success: function(resultDataSet) {
50
+ var resultData = _.cloneDeep(resultDataSet);
51
+ AppStatsGlobals["#graph_result_clicks"].OriginalData = resultData;
52
+ AppStatsGlobals["#graph_result_clicks"].Data = resultData;
53
+ sort_clicks_overview("#graph_result_clicks", AppStatsGlobals["#graph_result_clicks"].Sort);
54
+ },
55
+ error: function(result) {
56
+ error();
57
+ }
58
+ });
59
+ });
60
+ $.ajax({
61
+ type: "GET",
62
+ contentType: "application/json; charset=utf-8",
63
+ url: '<%= url_helper.data_module_clicks_path %>',
64
+ dataType: "json",
65
+ success: function(moduleDataSet) {
66
+ d3.select("#moduleIcon").transition().duration(250)
67
+ .style("opacity", .000001)
68
+ .remove();
69
+ var moduleData = _.cloneDeep(moduleDataSet);
70
+ AppStatsGlobals["#graph_module_clicks"].OriginalData = moduleData;
71
+ AppStatsGlobals["#graph_module_clicks"].Data = moduleData;
72
+ AppStatsGlobals["#graph_module_clicks"].Height = 450;
73
+ AppStatsGlobals["#graph_module_clicks"].Sort = 0;
74
+ draw_graph_clicks_overview("#graph_module_clicks", false);
75
+ },
76
+ error: function(result) {
77
+ error();
78
+ }
79
+ });
80
+ $.ajax({
81
+ type: "GET",
82
+ contentType: "application/json; charset=utf-8",
83
+ url: '<%= url_helper.data_result_clicks_path %>',
84
+ dataType: "json",
85
+ success: function(resultDataSet) {
86
+ d3.select("#resultIcon").transition().duration(250)
87
+ .style("opacity", .000001)
88
+ .remove();
89
+ var resultData = _.cloneDeep(resultDataSet);
90
+ AppStatsGlobals["#graph_result_clicks"].OriginalData = resultData;
91
+ AppStatsGlobals["#graph_result_clicks"].Data = resultData;
92
+ AppStatsGlobals["#graph_result_clicks"].Sort = 0;
93
+ AppStatsGlobals["#graph_result_clicks"].Height = 450;
94
+ draw_graph_clicks_overview("#graph_result_clicks", false);
95
+ },
96
+ error: function(result) {
97
+ error();
98
+ }
99
+ });
100
+ }
101
+ });
102
+
103
+ function error() {
104
+ console.log("Error retrieving data");
105
+ }
106
+
107
+ function draw_graph_clicks_overview(id, resetExpanded) {
108
+ if ($("#graph_module_clicks").length) {
109
+ // General Variables
110
+ var svg; // SVG to contain graph
111
+ var Globals; // Shortened reference to graphs globals (depends on id)
112
+ var dataInt; // Internal reference to graph dataset
113
+ var sortStates; // Array indicating the currently selected sort state
114
+ var key; // Key function to maintain object constancy
115
+ var triangle; // Triangle object for sort buttons
116
+ // Dimension Variables
117
+ var margin; // Blank space around edge of SVG left as margin
118
+ var rowHeight; // Height of each row of data
119
+ var width; // Drawable width of SVG (not including margins)
120
+ var height; // Drawable height of SVG (not including margins)
121
+ var oldHeight; // Previous height of SVG
122
+ var textPadding; // Padding around text elements
123
+ var barHeight; // Height of data bars
124
+ var rankWidth; // Width of rank column
125
+ var categoryWidth; // Width of category column
126
+ var countWidth; // Width of count column
127
+ var percentWidth; // Width of percent column
128
+ var childOffset; // Horizontal offset for child elements drawn on element expansion
129
+ var barCenter; // Center x for data bar
130
+ var triangleSpacing;// Space around triangular sort buttons
131
+ // Scale Variables
132
+ var x; // Scale for data bar
133
+ // Selection Variables
134
+ var groupEnter; // Entry selection for gAll
135
+ var gAll; // Group containing all elements
136
+ var headGroupEnter; // Entry selection for headRow
137
+ var headRow; // Group containing all head elements
138
+ var headEnter; // Entry selection for all head elements
139
+ var triangles; // Sort triangles
140
+ var dataGroupEnter; // Entry selection for dataRows
141
+ var dataRows; // Group containing all data elements
142
+ var dataRects; // Background rectangles
143
+ var dataRanks; // Rank text
144
+ var dataLabels; // Label text
145
+ var dataClicks; // Click text
146
+ var dataPercents; // Percent text
147
+ var dataBars; // Data bar
148
+ var lightBorder; // Light border (surrounds all elements)
149
+ var darkBorder; // Dark border (surrounds data elements)
150
+
151
+ // Initialize General Variables ///////////////////////////////////////////////////////////
152
+ svg = d3.select(id);
153
+
154
+ Globals = AppStatsGlobals[id];
155
+
156
+ dataInt = Globals.Data;
157
+
158
+ sortStates = [0, 0, 0, 0];
159
+ sortStates[Globals.Sort] = 1;
160
+
161
+ key = function(d) {
162
+ return d.key;
163
+ };
164
+
165
+ triangle = d3.symbol().type(d3.symbolTriangle).size(20);
166
+
167
+ // Initialize Dimension Variables /////////////////////////////////////////////////////////
168
+ margin = {
169
+ top: 20,
170
+ right: 20,
171
+ bottom: 20,
172
+ left: 20
173
+ };
174
+ rowHeight = 35;
175
+ width = +svg.attr("width") - margin.left - margin.right;
176
+ height = (dataInt.length + 1) * rowHeight;
177
+ oldHeight = Globals.Height;
178
+ textPadding = 5;
179
+ barHeight = 25;
180
+ rankWidth = width / 8;
181
+ categoryWidth = width / 4;
182
+ countWidth = 5 * width / 16;
183
+ percentWidth = 5 * width / 16;
184
+ childOffset = 25;
185
+ barCenter = rankWidth + categoryWidth + countWidth;
186
+ triangleSpacing = 15;
187
+
188
+ // Initialize Scale Variables /////////////////////////////////////////////////////////////
189
+ var x = d3.scaleLinear().rangeRound([0, countWidth + percentWidth - 200]);
190
+
191
+ x.domain([0, d3.max(dataInt, function(d) {
192
+ return d.clickcount
193
+ })]);
194
+
195
+ // Misc ///////////////////////////////////////////////////////////////////////////////////
196
+ // Transition the svg height depending on previous height
197
+ svg.transition().delay(function(d) {
198
+ if (oldHeight > height) {
199
+ return 500;
200
+ } else {
201
+ return 0;
202
+ }
203
+ })
204
+ .duration(750)
205
+ .attr("height", height + margin.top + margin.bottom)
206
+ .on("end", function(d) {
207
+ Globals.Height = height;
208
+ });
209
+
210
+ // Reset expanded categories when after a resort
211
+ if (resetExpanded) {
212
+ dataInt.forEach(function(d) {
213
+ d.expanded = 0;
214
+ });
215
+ }
216
+
217
+ // Make overarching group /////////////////////////////////////////////////////////////////
218
+ groupEnter = svg.selectAll("g").data([dataInt]).enter();
219
+
220
+ groupEnter.append("g")
221
+ .attr("class", "gAll");
222
+
223
+ gAll = svg.select(".gAll")
224
+ .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
225
+
226
+ // Make header row ////////////////////////////////////////////////////////////////////////
227
+ headGroupEnter = gAll.selectAll(".headRow").data([dataInt]).enter();
228
+
229
+ headGroupEnter.append("g")
230
+ .attr("class", "headRow");
231
+
232
+ headRow = gAll.select(".headRow")
233
+ .attr("transform", "translate(0,0)");
234
+
235
+ headEnter = headRow.selectAll("rect").data([dataInt]).enter();
236
+
237
+ // Make background rect
238
+ headEnter.append("rect")
239
+ .attr("class", "darkBar")
240
+ .attr("x", 0)
241
+ .attr("y", 0)
242
+ .attr("width", width)
243
+ .attr("height", rowHeight);
244
+
245
+ // Make rank text & sort rect
246
+ headEnter.append("text")
247
+ .text("Rank")
248
+ .attr("class", "headText")
249
+ .attr("transform", "translate(" + textPadding + "," + (rowHeight / 2 + textPadding) + ")");
250
+
251
+ headEnter.append("rect")
252
+ .attr("class", "sortRect")
253
+ .attr("x", (rankWidth - 2 * triangleSpacing))
254
+ .attr("y", 0)
255
+ .attr("width", 2 * triangleSpacing)
256
+ .attr("height", rowHeight)
257
+ .on("click", function(d) {
258
+ if (Globals.Sort == 0) {
259
+ sort_clicks_overview(id, 1);
260
+ } else {
261
+ sort_clicks_overview(id, 0);
262
+ }
263
+ });
264
+
265
+ // Make category text & sort rect
266
+ headEnter.append("text")
267
+ .text(function(d) {
268
+ if (id == "#graph_module_clicks") {
269
+ return "Module Clicked";
270
+ } else {
271
+ return "Result Clicked";
272
+ }
273
+ })
274
+ .attr("class", "headText")
275
+ .attr("transform", "translate(" + (rankWidth + textPadding) + "," + (rowHeight / 2 + textPadding) + ")");
276
+
277
+ headEnter.append("rect")
278
+ .attr("class", "sortRect")
279
+ .attr("x", (rankWidth + categoryWidth - 2 * triangleSpacing))
280
+ .attr("y", 0)
281
+ .attr("width", 2 * triangleSpacing)
282
+ .attr("height", rowHeight)
283
+ .on("click", function(d) {
284
+ if (Globals.Sort == 2) {
285
+ sort_clicks_overview(id, 3);
286
+ } else {
287
+ sort_clicks_overview(id, 2);
288
+ }
289
+ });
290
+
291
+ // Make count text
292
+ headEnter.append("text")
293
+ .text("Count")
294
+ .attr("class", "headText")
295
+ .attr("transform", "translate(" + (rankWidth + categoryWidth + textPadding) + "," + (rowHeight / 2 + textPadding) + ")");
296
+
297
+ // Make percent text
298
+ headEnter.append("text")
299
+ .text("Percent")
300
+ .attr("class", "percentText")
301
+ .attr("transform", "translate(" + (rankWidth + categoryWidth + countWidth + percentWidth - textPadding) + "," + (rowHeight / 2 + textPadding) + ")");
302
+
303
+ // Make sort triangles
304
+ triangles = headRow.selectAll("path").data(sortStates);
305
+
306
+ triangles.enter().append("path")
307
+ .attr("d", triangle)
308
+ .attr("pointer-events", "none")
309
+ .attr("transform", function(d, i) {
310
+ if (i == 0) {
311
+ return "translate(" + (rankWidth - triangleSpacing) + "," + (rowHeight / 2 - textPadding) + ")";
312
+ } else if (i == 1) {
313
+ return "translate(" + (rankWidth - triangleSpacing) + "," + (rowHeight / 2 + textPadding) + ") rotate(180)";
314
+ } else if (i == 2) {
315
+ return "translate(" + (rankWidth + categoryWidth - triangleSpacing) + "," + (rowHeight / 2 - textPadding) + ")";
316
+ } else if (i == 3) {
317
+ return "translate(" + (rankWidth + categoryWidth - triangleSpacing) + "," + (rowHeight / 2 + textPadding) + ") rotate(180)";
318
+ }
319
+ })
320
+ .merge(triangles)
321
+ .transition().duration(500)
322
+ .attr("fill", function(d, i) {
323
+ if (d) {
324
+ return "steelblue";
325
+ } else {
326
+ return "lightsteelblue";
327
+ }
328
+ });
329
+
330
+ // Make data rows /////////////////////////////////////////////////////////////////////////
331
+ dataGroupEnter = gAll.selectAll(".dataRows").data([dataInt]).enter();
332
+
333
+ dataGroupEnter.append("g")
334
+ .attr("class", "dataRows");
335
+
336
+ dataRows = gAll.select(".dataRows")
337
+ .attr("transform", "translate(0,0)");
338
+
339
+ // Make background rects
340
+ dataRects = dataRows.selectAll(".darkBar, .lightBar").data(dataInt, key);
341
+
342
+ dataRects.transition().delay(function(d) {
343
+ if (oldHeight > height) {
344
+ return 500;
345
+ } else {
346
+ return 0;
347
+ }
348
+ })
349
+ .duration(500)
350
+ .attr("y", function(d, i) {
351
+ return (i + 1) * rowHeight;
352
+ });
353
+ dataRects.exit().remove();
354
+ dataRects.enter().append("rect")
355
+ .attr("class", function(d, i) {
356
+ if (d.parent) {
357
+ return "lightBar";
358
+ } else {
359
+ return "darkBar";
360
+ }
361
+ })
362
+ .attr("x", 0)
363
+ .attr("y", function(d, i) {
364
+ return (i + 1) * rowHeight;
365
+ })
366
+ .attr("width", width)
367
+ .attr("height", rowHeight);
368
+
369
+ // Make rank text
370
+ dataRanks = dataRows.selectAll(".dataRank").data(dataInt, key);
371
+
372
+ dataRanks.transition().delay(function(d) {
373
+ if (oldHeight > height) {
374
+ return 500;
375
+ } else {
376
+ return 0;
377
+ }
378
+ })
379
+ .duration(500)
380
+ .attr("transform", function(d, i) {
381
+ if (!d.parent) {
382
+ return "translate(" + textPadding + "," + Math.floor((i + 1) * rowHeight + rowHeight / 2 + textPadding) + ")";
383
+ } else {
384
+ return "translate(" + (textPadding + childOffset) + "," + Math.floor((i + 1) * rowHeight + rowHeight / 2 + textPadding) + ")";
385
+ }
386
+ })
387
+ .text(function(d) {
388
+ return d.rank;
389
+ });
390
+ dataRanks.exit().transition().duration(500)
391
+ .style("opacity", .000001)
392
+ .remove();
393
+ dataRanks.enter().append("text")
394
+ .style("opacity", .000001)
395
+ .text(function(d) {
396
+ return d.rank;
397
+ })
398
+ .attr("class", "dataRank")
399
+ .attr("transform", function(d, i) {
400
+ if (!d.parent) {
401
+ return "translate(" + textPadding + "," + Math.floor((i + 1) * rowHeight + rowHeight / 2 + textPadding) + ")";
402
+ } else {
403
+ return "translate(" + (textPadding + childOffset) + "," + Math.floor((i + 1) * rowHeight + rowHeight / 2 + textPadding) + ")";
404
+ }
405
+ })
406
+ .transition().delay(750).duration(500)
407
+ .style("opacity", 1);
408
+
409
+ // Make label text
410
+ dataLabels = dataRows.selectAll(".dataLabel").data(dataInt, key);
411
+
412
+ dataLabels.transition().delay(function(d) {
413
+ if (oldHeight > height) {
414
+ return 500;
415
+ } else {
416
+ return 0;
417
+ }
418
+ })
419
+ .duration(500)
420
+ .attr("transform", function(d, i) {
421
+ if (!d.parent) {
422
+ return "translate(" + (rankWidth + textPadding) + "," + Math.floor((i + 1) * rowHeight + rowHeight / 2 + textPadding) + ")";
423
+ } else {
424
+ return "translate(" + (rankWidth + textPadding + childOffset) + "," + Math.floor((i + 1) * rowHeight + rowHeight / 2 + textPadding) + ")";
425
+ }
426
+ });
427
+ dataLabels.exit().transition().duration(500)
428
+ .style("opacity", .000001)
429
+ .remove();
430
+ dataLabels.enter().append("text")
431
+ .style("opacity", .000001)
432
+ .text(function(d) {
433
+ if (d.label.length > 25) {
434
+ return d.label.slice(0, 20) + "...";
435
+ } else {
436
+ return d.label;
437
+ }
438
+ })
439
+ .attr("class", "dataLabel")
440
+ .attr("transform", function(d, i) {
441
+ if (!d.parent) {
442
+ return "translate(" + (rankWidth + textPadding) + "," + Math.floor((i + 1) * rowHeight + rowHeight / 2 + textPadding) + ")";
443
+ } else {
444
+ return "translate(" + (rankWidth + textPadding + childOffset) + "," + Math.floor((i + 1) * rowHeight + rowHeight / 2 + textPadding) + ")";
445
+ }
446
+ })
447
+ .transition().delay(750).duration(500)
448
+ .style("opacity", 1);
449
+
450
+ // Make click text
451
+ dataClicks = dataRows.selectAll(".dataClick").data(dataInt, key);
452
+
453
+ dataClicks.transition().delay(function(d) {
454
+ if (oldHeight > height) {
455
+ return 500;
456
+ } else {
457
+ return 0;
458
+ }
459
+ })
460
+ .duration(500)
461
+ .attr("transform", function(d, i) {
462
+ if (!d.parent) {
463
+ return "translate(" + (rankWidth + categoryWidth + textPadding) + "," + Math.floor((i + 1) * rowHeight + rowHeight / 2 + textPadding) + ")";
464
+ } else {
465
+ return "translate(" + (rankWidth + categoryWidth + textPadding + childOffset) + "," + Math.floor((i + 1) * rowHeight + rowHeight / 2 + textPadding) + ")";
466
+ }
467
+ })
468
+ .text(function(d) {
469
+ return d.clickcount;
470
+ });
471
+ dataClicks.exit().transition().duration(500)
472
+ .style("opacity", .000001)
473
+ .remove();
474
+ dataClicks.enter().append("text")
475
+ .style("opacity", .000001)
476
+ .text(function(d) {
477
+ return d.clickcount;
478
+ })
479
+ .attr("class", "dataClick")
480
+ .attr("transform", function(d, i) {
481
+ if (!d.parent) {
482
+ return "translate(" + (rankWidth + categoryWidth + textPadding) + "," + Math.floor((i + 1) * rowHeight + rowHeight / 2 + textPadding) + ")";
483
+ } else {
484
+ return "translate(" + (rankWidth + categoryWidth + textPadding + childOffset) + "," + Math.floor((i + 1) * rowHeight + rowHeight / 2 + textPadding) + ")";
485
+ }
486
+ })
487
+ .transition().delay(750).duration(500)
488
+ .style("opacity", 1);
489
+
490
+ // Make percent text
491
+ dataPercents = dataRows.selectAll(".dataPercent").data(dataInt, key);
492
+
493
+ dataPercents.transition().delay(function(d) {
494
+ if (oldHeight > height) {
495
+ return 500;
496
+ } else {
497
+ return 0;
498
+ }
499
+ })
500
+ .duration(500)
501
+ .attr("transform", function(d, i) {
502
+ if (!d.parent) {
503
+ return "translate(" + (rankWidth + categoryWidth + countWidth + percentWidth - textPadding) + "," + Math.floor((i + 1) * rowHeight + rowHeight / 2 + textPadding) + ")";
504
+ } else {
505
+ return "translate(" + (rankWidth + categoryWidth + countWidth + percentWidth - textPadding - childOffset) + "," + Math.floor((i + 1) * rowHeight + rowHeight / 2 + textPadding) + ")";
506
+ }
507
+ })
508
+ .text(function(d) {
509
+ return d.percentage + "%";
510
+ });
511
+ dataPercents.exit().transition().duration(500)
512
+ .style("opacity", .000001)
513
+ .remove();
514
+ dataPercents.enter().append("text")
515
+ .style("opacity", .000001)
516
+ .text(function(d) {
517
+ return d.percentage + "%";
518
+ })
519
+ .attr("class", "dataPercent")
520
+ .attr("transform", function(d, i) {
521
+ if (!d.parent) {
522
+ return "translate(" + (rankWidth + categoryWidth + countWidth + percentWidth - textPadding) + "," + Math.floor((i + 1) * rowHeight + rowHeight / 2 + textPadding) + ")";
523
+ } else {
524
+ return "translate(" + (rankWidth + categoryWidth + countWidth + percentWidth - textPadding - childOffset) + "," + Math.floor((i + 1) * rowHeight + rowHeight / 2 + textPadding) + ")";
525
+ }
526
+ })
527
+ .transition().delay(750).duration(500)
528
+ .style("opacity", 1);
529
+
530
+ // Make data bars
531
+ dataBars = dataRows.selectAll(".dataBar, .lightDataBar").data(dataInt, key);
532
+
533
+ dataBars.transition().delay(function(d) {
534
+ if (oldHeight > height) {
535
+ return 500;
536
+ } else {
537
+ return 0;
538
+ }
539
+ })
540
+ .duration(500)
541
+ .attr("y", function(d, i) {
542
+ return (i + 1) * rowHeight + (rowHeight - barHeight) / 2;
543
+ })
544
+ .attr("x", function(d) {
545
+ return barCenter - x(d.clickcount) / 2;
546
+ })
547
+ .attr("width", function(d) {
548
+ return x(d.clickcount);
549
+ });
550
+ dataBars.exit().transition().duration(500)
551
+ .attr("x", barCenter)
552
+ .attr("width", 0)
553
+ .remove();
554
+ dataBars.enter().append("rect")
555
+ .attr("class", function(d) {
556
+ if (!d.parent) {
557
+ return "dataBar";
558
+ } else {
559
+ return "lightDataBar";
560
+ }
561
+ })
562
+ .attr("x", function(d) {
563
+ return barCenter;
564
+ })
565
+ .attr("y", function(d, i) {
566
+ return (i + 1) * rowHeight + (rowHeight - barHeight) / 2;
567
+ })
568
+ .attr("width", function(d) {
569
+ return 0;
570
+ })
571
+ .attr("height", barHeight)
572
+ .style("cursor", function(d) {
573
+ if (id == "#graph_module_clicks" && !d.parent) {
574
+ return "pointer";
575
+ } else {
576
+ return "auto";
577
+ }
578
+ })
579
+ .on("click", function(d) { expand(d,id) })
580
+ .transition().delay(750).duration(500)
581
+ .attr("x", function(d) {
582
+ return barCenter - x(d.clickcount) / 2;
583
+ })
584
+ .attr("width", function(d) {
585
+ return x(d.clickcount);
586
+ });
587
+
588
+ // Add borders ////////////////////////////////////////////////////////////////////////////
589
+ lightBorder = gAll.selectAll(".lightBorder").data([dataInt]);
590
+
591
+ lightBorder.transition().delay(function(d) {
592
+ if (oldHeight > height) {
593
+ return 500;
594
+ } else {
595
+ return 0;
596
+ }
597
+ })
598
+ .duration(500)
599
+ .attr("height", height);
600
+ lightBorder.exit().remove();
601
+ lightBorder.enter().append("rect")
602
+ .attr("class", "lightBorder")
603
+ .attr("x", 0)
604
+ .attr("y", 0)
605
+ .attr("width", width)
606
+ .attr("height", height);;
607
+
608
+ darkBorder = gAll.selectAll(".darkBorder").data([dataInt]);
609
+
610
+ darkBorder.transition().delay(function(d) {
611
+ if (oldHeight > height) {
612
+ return 500;
613
+ } else {
614
+ return 0;
615
+ }
616
+ })
617
+ .duration(500)
618
+ .attr("height", height - rowHeight);
619
+ darkBorder.exit().remove();
620
+ darkBorder.enter().append("rect")
621
+ .attr("class", "darkBorder")
622
+ .attr("x", 0)
623
+ .attr("y", rowHeight)
624
+ .attr("width", width)
625
+ .attr("height", height - rowHeight);
626
+ }
627
+ }
628
+
629
+ function expand(d, id) {
630
+ if (id == "#graph_module_clicks" && !d.expanded && !d.parent) {
631
+ d.expanded = 1;
632
+ load_details(d.label, id);
633
+ } else if (id == "#graph_module_clicks" && d.expanded && !d.parent) {
634
+ d.expanded = 0;
635
+ remove_details(d.label, id);
636
+ }
637
+ }
638
+
639
+ function sort_clicks_overview(id, sort) {
640
+ if (AppStatsGlobals[id].Data.length != AppStatsGlobals[id].OriginalData.length) { // If details are present, those must be removed before resort
641
+ // Go back to original data set (no details)
642
+ AppStatsGlobals[id].Data = AppStatsGlobals[id].OriginalData.sort(function(a, b) {
643
+ return determine_sort(AppStatsGlobals[id].Sort, a, b)
644
+ });
645
+
646
+ // Resort data after delay
647
+ setTimeout(function() {
648
+ AppStatsGlobals[id].Data = AppStatsGlobals[id].OriginalData.sort(function(a, b) {
649
+ return determine_sort(sort, a, b)
650
+ });
651
+ draw_graph_clicks_overview(id, true);
652
+ }, 750);
653
+ } else { // Otherwise, you can just resort the data
654
+ AppStatsGlobals[id].Data = AppStatsGlobals[id].OriginalData.sort(function(a, b) {
655
+ return determine_sort(sort, a, b)
656
+ });
657
+ }
658
+
659
+ // Update global sort
660
+ AppStatsGlobals[id].Sort = sort;
661
+ draw_graph_clicks_overview(id, true);
662
+ }
663
+
664
+ function determine_sort(sort, a, b) {
665
+ switch (sort) {
666
+ case 0: return d3.ascending(a.rank, b.rank);
667
+ case 1: return d3.ascending(b.rank, a.rank);
668
+
669
+ case 2: return d3.ascending(a.label, b.label);
670
+ case 3: return d3.ascending(b.label, a.label);
671
+ }
672
+ }
673
+
674
+ function load_details(category, id) {
675
+ var updateData = _.cloneDeep(AppStatsGlobals[id].Data);
676
+ var from = $("#from").datepicker("getDate");
677
+ var to = new Date($("#to").datepicker("getDate").getTime() + 1000 * 60 * 60 * 24);
678
+ $.ajax({
679
+ type: "GET",
680
+ contentType: "application/json; charset=utf-8",
681
+ url: '<%= url_helper.data_module_details_path %>',
682
+ dataType: "json",
683
+ data: {
684
+ "category": category,
685
+ "start_date": from,
686
+ "end_date": to
687
+ },
688
+ success: function(detailSet) {
689
+ var detailData = _.cloneDeep(detailSet);
690
+ var index = _.findIndex(updateData, {
691
+ "label": category
692
+ });
693
+ updateData = _.concat(_.slice(updateData, 0, index + 1), detailData, _.slice(updateData, index + 1, updateData.length));
694
+
695
+ AppStatsGlobals[id].Data = updateData;
696
+ draw_graph_clicks_overview(id, false);
697
+ },
698
+ error: function(result) {
699
+ error();
700
+ }
701
+ });
702
+ }
703
+
704
+ function remove_details(category, id) {
705
+ var updateData = _.cloneDeep(AppStatsGlobals[id].Data);
706
+ var startIndex = _.findIndex(updateData, {
707
+ "label": category
708
+ });
709
+ var endIndex = startIndex + 1;
710
+ while (endIndex < updateData.length && updateData[endIndex].parent) {
711
+ endIndex++;
712
+ }
713
+ updateData = _.concat(_.slice(updateData, 0, startIndex + 1), _.slice(updateData, endIndex, updateData.length));
714
+
715
+ AppStatsGlobals[id].Data = updateData;
716
+ draw_graph_clicks_overview(id, false);
717
+ }
718
+
719
+ })();