qa_server 7.1.3 → 7.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop_fixme.yml +6 -0
  3. data/.travis.yml +4 -5
  4. data/CHANGELOG.md +36 -0
  5. data/Rakefile +1 -1
  6. data/app/assets/stylesheets/qa_server/_check-status.scss +36 -0
  7. data/app/cache_processors/concerns/qa_server/cache_keys.rb +0 -5
  8. data/app/cache_processors/qa_server/cache_expiry_service.rb +13 -8
  9. data/app/cache_processors/qa_server/job_id_cache.rb +29 -0
  10. data/app/cache_processors/qa_server/performance_cache.rb +34 -34
  11. data/app/cache_processors/qa_server/performance_day_graph_cache.rb +27 -0
  12. data/app/cache_processors/qa_server/performance_month_graph_cache.rb +27 -0
  13. data/app/cache_processors/qa_server/performance_year_graph_cache.rb +27 -0
  14. data/app/cache_processors/qa_server/scenario_history_cache.rb +7 -7
  15. data/app/cache_processors/qa_server/scenario_history_graph_cache.rb +12 -18
  16. data/app/cache_processors/qa_server/scenario_run_cache.rb +8 -8
  17. data/app/cache_processors/qa_server/scenario_run_failures_cache.rb +7 -7
  18. data/app/cache_processors/qa_server/scenario_run_summary_cache.rb +7 -7
  19. data/app/controllers/concerns/qa_server/authority_validation_behavior.rb +49 -44
  20. data/app/controllers/qa_server/check_status_controller.rb +92 -22
  21. data/app/controllers/qa_server/fetch_controller.rb +36 -36
  22. data/app/controllers/qa_server/monitor_status_controller.rb +105 -105
  23. data/app/jobs/qa_server/history_graph_job.rb +28 -0
  24. data/app/jobs/qa_server/monitor_tests_job.rb +19 -39
  25. data/app/jobs/qa_server/performance_day_graph_job.rb +45 -0
  26. data/app/jobs/qa_server/performance_month_graph_job.rb +45 -0
  27. data/app/jobs/qa_server/performance_per_byte_job.rb +85 -0
  28. data/app/jobs/qa_server/performance_year_graph_job.rb +45 -0
  29. data/app/loggers/qa_server/scenario_logger.rb +74 -4
  30. data/app/models/concerns/qa_server/performance_history_data_keys.rb +8 -0
  31. data/app/models/qa_server/authority_scenario.rb +4 -4
  32. data/app/models/qa_server/authority_status.rb +2 -2
  33. data/app/models/qa_server/authority_status_failure.rb +1 -1
  34. data/app/models/qa_server/performance_history.rb +2 -2
  35. data/app/models/qa_server/scenario_run_history.rb +52 -52
  36. data/app/models/qa_server/scenario_run_registry.rb +2 -2
  37. data/app/models/qa_server/scenarios.rb +26 -26
  38. data/app/models/qa_server/search_scenario.rb +18 -13
  39. data/app/models/qa_server/term_scenario.rb +29 -29
  40. data/app/prepends/prepended_linked_data/find_term.rb +40 -40
  41. data/app/prepends/prepended_linked_data/search_query.rb +36 -36
  42. data/app/prepends/prepended_rdf/rdf_graph.rb +7 -7
  43. data/app/presenters/concerns/qa_server/monitor_status/performance_datatable_behavior.rb +32 -32
  44. data/app/presenters/concerns/qa_server/monitor_status/performance_graph_behavior.rb +64 -65
  45. data/app/presenters/qa_server/check_status_presenter.rb +63 -7
  46. data/app/presenters/qa_server/monitor_status/history_presenter.rb +0 -2
  47. data/app/presenters/qa_server/monitor_status/performance_presenter.rb +0 -1
  48. data/app/services/concerns/qa_server/gruff_graph.rb +28 -0
  49. data/app/services/qa_server/authority_loader_service.rb +14 -14
  50. data/app/services/qa_server/authority_validator_service.rb +1 -0
  51. data/app/services/qa_server/database_migrator.rb +14 -14
  52. data/app/services/qa_server/history_graphing_service.rb +32 -36
  53. data/app/services/qa_server/performance_calculator_service.rb +80 -80
  54. data/app/services/qa_server/performance_datatable_service.rb +35 -35
  55. data/app/services/qa_server/performance_graph_data_service.rb +28 -28
  56. data/app/services/qa_server/performance_graphing_service.rb +60 -60
  57. data/app/services/qa_server/performance_per_byte_calculator_service.rb +88 -0
  58. data/app/services/qa_server/performance_per_byte_data_service.rb +41 -0
  59. data/app/services/qa_server/scenarios_loader_service.rb +1 -1
  60. data/app/services/qa_server/time_period_service.rb +21 -21
  61. data/app/validators/qa_server/scenario_validator.rb +99 -87
  62. data/app/validators/qa_server/search_scenario_validator.rb +67 -61
  63. data/app/validators/qa_server/term_scenario_validator.rb +20 -15
  64. data/app/views/qa_server/check_status/index.html.erb +120 -24
  65. data/config/locales/qa_server.en.yml +1 -0
  66. data/lib/generators/qa_server/assets_generator.rb +4 -4
  67. data/lib/generators/qa_server/templates/config/authorities/linked_data/cerl_ld4l_cache.json +2 -2
  68. data/lib/generators/qa_server/templates/config/authorities/linked_data/getty_aat_ld4l_cache.json +62 -1
  69. data/lib/generators/qa_server/templates/config/authorities/linked_data/getty_tgn_ld4l_cache.json +28 -4
  70. data/lib/generators/qa_server/templates/config/authorities/linked_data/isni_ld4l_cache.json +90 -0
  71. data/lib/generators/qa_server/templates/config/authorities/linked_data/ligatus_ld4l_cache.json +133 -0
  72. data/lib/generators/qa_server/templates/config/authorities/linked_data/locnames_rwo2_ld4l_cache.json +248 -0
  73. data/lib/generators/qa_server/templates/config/authorities/linked_data/locnames_rwo3_ld4l_cache.json +248 -0
  74. data/lib/generators/qa_server/templates/config/authorities/linked_data/locvocabs_ld4l_cache.json +117 -0
  75. data/lib/generators/qa_server/templates/config/authorities/linked_data/mesh_nlm_ld4l_cache.json +135 -3
  76. data/lib/generators/qa_server/templates/config/authorities/linked_data/oclcfast_direct.json +1 -0
  77. data/lib/generators/qa_server/templates/config/authorities/linked_data/oclcfast_ld4l_cache.json +1 -4
  78. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/agrovoc_direct_validation.yml +31 -0
  79. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/agrovoc_ld4l_cache_validation.yml +31 -0
  80. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/cerl_ld4l_cache_validation.yml +23 -11
  81. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/dbpedia_ld4l_cache_validation.yml +33 -0
  82. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/geonames_direct_validation.yml +35 -0
  83. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/geonames_ld4l_cache_validation.yml +58 -5
  84. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/getty_aat_ld4l_cache_validation.yml +256 -0
  85. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/getty_tgn_ld4l_cache_validation.yml +35 -1
  86. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/getty_ulan_ld4l_cache_validation.yml +37 -0
  87. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/isni_ld4l_cache_validation.yml +10 -0
  88. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/ligatus_ld4l_cache_validation.yml +36 -0
  89. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locdemographics_ld4l_cache_validation.yml +73 -44
  90. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locgenres_ld4l_cache_validation.yml +31 -0
  91. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locnames_ld4l_cache_validation.yml +71 -0
  92. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locnames_rwo_ld4l_cache_validation.yml +70 -2
  93. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locperformance_ld4l_cache_validation.yml +6 -0
  94. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locsubjects_ld4l_cache_validation.yml +32 -0
  95. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locvocabs_ld4l_cache_validation.yml +184 -0
  96. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/mesh_nlm_ld4l_cache_validation.yml +51 -1
  97. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/nalt_ld4l_cache_validation.yml +37 -0
  98. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/oclc_fast_validation.yml +71 -5
  99. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/oclcfast_direct_validation.yml +66 -1
  100. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/oclcfast_ld4l_cache_validation.yml +57 -0
  101. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/rda_registry_ld4l_cache_validation.yml +310 -0
  102. data/lib/qa_server/configuration.rb +28 -24
  103. data/lib/qa_server/version.rb +1 -1
  104. data/qa_server.gemspec +1 -1
  105. data/spec/feature/accuracy_spec.rb +32 -0
  106. data/spec/spec_helper.rb +4 -0
  107. metadata +30 -13
  108. data/app/cache_processors/qa_server/performance_daily_graph_cache.rb +0 -60
  109. data/app/cache_processors/qa_server/performance_hourly_graph_cache.rb +0 -65
  110. data/app/cache_processors/qa_server/performance_monthly_graph_cache.rb +0 -60
  111. data/app/presenters/concerns/qa_server/monitor_status/gruff_graph.rb +0 -20
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module QaServer
3
- VERSION = '7.1.3'
3
+ VERSION = '7.5.0'
4
4
  end
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
 
35
35
  spec.add_development_dependency 'better_errors' # provide debugging command line in
36
36
  spec.add_development_dependency 'binding_of_caller' # provides deep stack info used by better_errors
37
- spec.add_development_dependency 'bixby', '~> 1.0.0' # rubocop styleguide
37
+ spec.add_development_dependency 'bixby', '~> 3.0.0' # rubocop styleguide
38
38
  # spec.add_development_dependency "capybara", '~> 3.29'
39
39
  # spec.add_development_dependency 'capybara-maleficent', '~> 0.3.0'
40
40
  # spec.add_development_dependency 'chromedriver-helper', '~> 2.1'
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+
4
+ # rubocop:disable RSpec/InstanceVariable
5
+ RSpec.describe 'Accuracy test' do # rubocop:disable RSpec/DescribeClass
6
+ before(:all) { WebMock.allow_net_connect! }
7
+ after(:all) { WebMock.disable_net_connect! }
8
+
9
+ let(:authority_list) { QaServer::AuthorityListerService.authorities_list }
10
+ let(:authority_name) { :CERL_LD4L_CACHE }
11
+
12
+ describe 'for authority:' do
13
+ @status_log = QaServer::ScenarioLogger.new
14
+ QaServer::AuthorityListerService.authorities_list.each do |authority_name| # rubocop:disable Style/MultilineIfModifier
15
+ QaServer::AuthorityValidatorService.run(authority_name: authority_name,
16
+ status_log: @status_log,
17
+ validation_type: QaServer::ScenarioValidator::VALIDATE_ACCURACY)
18
+ end unless ENV['TRAVIS']
19
+ @status_log.each do |test_result|
20
+ context "#{test_result[:authority_name]}:#{test_result[:subauthority_name]}:#{test_result[:request_data]}:" do
21
+ it "finds actual <= expected" do
22
+ pending 'test is known to fail' if test_result[:pending]
23
+ expect(test_result[:err_message]).to be_empty
24
+ expect(test_result[:request_data]).not_to be_empty
25
+ expect(test_result[:actual]).not_to be_nil
26
+ expect(test_result[:actual]).to be <= test_result[:expected]
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ # rubocop:enable RSpec/InstanceVariable
@@ -62,3 +62,7 @@ def load_fixture_file(fname)
62
62
  return f.read
63
63
  end
64
64
  end
65
+
66
+ QaServer.config.suppress_performance_gathering = true
67
+ QaServer.config.suppress_logging_performance_details = true
68
+ QaServer.config.preferred_time_zone_name = 'Eastern Time (US & Canada)'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qa_server
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.3
4
+ version: 7.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - E. Lynette Rayle
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-22 00:00:00.000000000 Z
11
+ date: 2020-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 1.0.0
117
+ version: 3.0.0
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 1.0.0
124
+ version: 3.0.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: deprecation
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -340,11 +340,12 @@ files:
340
340
  - app/assets/stylesheets/qa_server/_usage.scss
341
341
  - app/cache_processors/concerns/qa_server/cache_keys.rb
342
342
  - app/cache_processors/qa_server/cache_expiry_service.rb
343
+ - app/cache_processors/qa_server/job_id_cache.rb
343
344
  - app/cache_processors/qa_server/performance_cache.rb
344
- - app/cache_processors/qa_server/performance_daily_graph_cache.rb
345
345
  - app/cache_processors/qa_server/performance_datatable_cache.rb
346
- - app/cache_processors/qa_server/performance_hourly_graph_cache.rb
347
- - app/cache_processors/qa_server/performance_monthly_graph_cache.rb
346
+ - app/cache_processors/qa_server/performance_day_graph_cache.rb
347
+ - app/cache_processors/qa_server/performance_month_graph_cache.rb
348
+ - app/cache_processors/qa_server/performance_year_graph_cache.rb
348
349
  - app/cache_processors/qa_server/scenario_history_cache.rb
349
350
  - app/cache_processors/qa_server/scenario_history_graph_cache.rb
350
351
  - app/cache_processors/qa_server/scenario_run_cache.rb
@@ -357,7 +358,12 @@ files:
357
358
  - app/controllers/qa_server/homepage_controller.rb
358
359
  - app/controllers/qa_server/monitor_status_controller.rb
359
360
  - app/controllers/qa_server/usage_controller.rb
361
+ - app/jobs/qa_server/history_graph_job.rb
360
362
  - app/jobs/qa_server/monitor_tests_job.rb
363
+ - app/jobs/qa_server/performance_day_graph_job.rb
364
+ - app/jobs/qa_server/performance_month_graph_job.rb
365
+ - app/jobs/qa_server/performance_per_byte_job.rb
366
+ - app/jobs/qa_server/performance_year_graph_job.rb
361
367
  - app/loggers/qa_server/scenario_logger.rb
362
368
  - app/models/concerns/qa_server/performance_history_data_keys.rb
363
369
  - app/models/qa_server/authority_scenario.rb
@@ -373,7 +379,6 @@ files:
373
379
  - app/prepends/prepended_linked_data/find_term.rb
374
380
  - app/prepends/prepended_linked_data/search_query.rb
375
381
  - app/prepends/prepended_rdf/rdf_graph.rb
376
- - app/presenters/concerns/qa_server/monitor_status/gruff_graph.rb
377
382
  - app/presenters/concerns/qa_server/monitor_status/performance_datatable_behavior.rb
378
383
  - app/presenters/concerns/qa_server/monitor_status/performance_graph_behavior.rb
379
384
  - app/presenters/qa_server/authority_list_presenter.rb
@@ -384,6 +389,7 @@ files:
384
389
  - app/presenters/qa_server/monitor_status/performance_presenter.rb
385
390
  - app/presenters/qa_server/monitor_status_presenter.rb
386
391
  - app/presenters/qa_server/navmenu_presenter.rb
392
+ - app/services/concerns/qa_server/gruff_graph.rb
387
393
  - app/services/qa_server/authority_lister_service.rb
388
394
  - app/services/qa_server/authority_loader_service.rb
389
395
  - app/services/qa_server/authority_validator_service.rb
@@ -393,6 +399,8 @@ files:
393
399
  - app/services/qa_server/performance_datatable_service.rb
394
400
  - app/services/qa_server/performance_graph_data_service.rb
395
401
  - app/services/qa_server/performance_graphing_service.rb
402
+ - app/services/qa_server/performance_per_byte_calculator_service.rb
403
+ - app/services/qa_server/performance_per_byte_data_service.rb
396
404
  - app/services/qa_server/scenarios_loader_service.rb
397
405
  - app/services/qa_server/time_period_service.rb
398
406
  - app/services/qa_server/time_service.rb
@@ -429,13 +437,18 @@ files:
429
437
  - lib/generators/qa_server/templates/config/authorities/linked_data/getty_aat_ld4l_cache.json
430
438
  - lib/generators/qa_server/templates/config/authorities/linked_data/getty_tgn_ld4l_cache.json
431
439
  - lib/generators/qa_server/templates/config/authorities/linked_data/getty_ulan_ld4l_cache.json
440
+ - lib/generators/qa_server/templates/config/authorities/linked_data/isni_ld4l_cache.json
441
+ - lib/generators/qa_server/templates/config/authorities/linked_data/ligatus_ld4l_cache.json
432
442
  - lib/generators/qa_server/templates/config/authorities/linked_data/loc_direct.json
433
443
  - lib/generators/qa_server/templates/config/authorities/linked_data/locdemographics_ld4l_cache.json
434
444
  - lib/generators/qa_server/templates/config/authorities/linked_data/locgenres_ld4l_cache.json
435
445
  - lib/generators/qa_server/templates/config/authorities/linked_data/locnames_ld4l_cache.json
446
+ - lib/generators/qa_server/templates/config/authorities/linked_data/locnames_rwo2_ld4l_cache.json
447
+ - lib/generators/qa_server/templates/config/authorities/linked_data/locnames_rwo3_ld4l_cache.json
436
448
  - lib/generators/qa_server/templates/config/authorities/linked_data/locnames_rwo_ld4l_cache.json
437
449
  - lib/generators/qa_server/templates/config/authorities/linked_data/locperformance_ld4l_cache.json
438
450
  - lib/generators/qa_server/templates/config/authorities/linked_data/locsubjects_ld4l_cache.json
451
+ - lib/generators/qa_server/templates/config/authorities/linked_data/locvocabs_ld4l_cache.json
439
452
  - lib/generators/qa_server/templates/config/authorities/linked_data/mesh_nlm_ld4l_cache.json
440
453
  - lib/generators/qa_server/templates/config/authorities/linked_data/nalt_direct.json
441
454
  - lib/generators/qa_server/templates/config/authorities/linked_data/nalt_ld4l_cache.json
@@ -452,6 +465,8 @@ files:
452
465
  - lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/getty_aat_ld4l_cache_validation.yml
453
466
  - lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/getty_tgn_ld4l_cache_validation.yml
454
467
  - lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/getty_ulan_ld4l_cache_validation.yml
468
+ - lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/isni_ld4l_cache_validation.yml
469
+ - lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/ligatus_ld4l_cache_validation.yml
455
470
  - lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/loc_direct_validation.yml
456
471
  - lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/loc_validation.yml
457
472
  - lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locdemographics_ld4l_cache_validation.yml
@@ -460,6 +475,7 @@ files:
460
475
  - lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locnames_rwo_ld4l_cache_validation.yml
461
476
  - lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locperformance_ld4l_cache_validation.yml
462
477
  - lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locsubjects_ld4l_cache_validation.yml
478
+ - lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locvocabs_ld4l_cache_validation.yml
463
479
  - lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/mesh_nlm_ld4l_cache_validation.yml
464
480
  - lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/nalt_direct_validation.yml
465
481
  - lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/nalt_ld4l_cache_validation.yml
@@ -491,6 +507,7 @@ files:
491
507
  - qa_server.gemspec
492
508
  - spec/.gitignore
493
509
  - spec/cache_processors/qa_server/cache_expiry_service_spec.rb
510
+ - spec/feature/accuracy_spec.rb
494
511
  - spec/lib/configuration_spec.rb
495
512
  - spec/lib/qa_server_spec.rb
496
513
  - spec/rails_helper.rb
@@ -505,7 +522,7 @@ homepage: http://github.com/LD4P/qa_server
505
522
  licenses:
506
523
  - Apache-2.0
507
524
  metadata: {}
508
- post_install_message:
525
+ post_install_message:
509
526
  rdoc_options: []
510
527
  require_paths:
511
528
  - lib
@@ -520,14 +537,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
520
537
  - !ruby/object:Gem::Version
521
538
  version: '0'
522
539
  requirements: []
523
- rubyforge_project:
524
- rubygems_version: 2.6.14
525
- signing_key:
540
+ rubygems_version: 3.0.8
541
+ signing_key:
526
542
  specification_version: 4
527
543
  summary: Authority Lookup Server
528
544
  test_files:
529
545
  - spec/.gitignore
530
546
  - spec/cache_processors/qa_server/cache_expiry_service_spec.rb
547
+ - spec/feature/accuracy_spec.rb
531
548
  - spec/lib/configuration_spec.rb
532
549
  - spec/lib/qa_server_spec.rb
533
550
  - spec/rails_helper.rb
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
- # Generate graphs for the past 30 days using cached data. Graphs are generated only if the cache has expired.
3
- module QaServer
4
- class PerformanceDailyGraphCache
5
- class_attribute :authority_list_class, :graph_data_service, :graphing_service
6
- self.authority_list_class = QaServer::AuthorityListerService
7
- self.graph_data_service = QaServer::PerformanceGraphDataService
8
- self.graphing_service = QaServer::PerformanceGraphingService
9
-
10
- class << self
11
- include QaServer::CacheKeys
12
- include QaServer::PerformanceHistoryDataKeys
13
-
14
- # Generates graphs for the past 30 days for :search, :fetch, and :all actions for each authority.
15
- # @param force [Boolean] if true, run the tests even if the cache hasn't expired; otherwise, use cache if not expired
16
- def generate_graphs(force: false)
17
- return unless QaServer::CacheExpiryService.cache_expired?(key: cache_key_for_force, force: force, next_expiry: next_expiry)
18
- QaServer.config.monitor_logger.debug("(QaServer::PerformanceDailyGraphCache) - GENERATING daily performance graphs (force: #{force})")
19
- generate_graphs_for_authorities
20
- end
21
-
22
- private
23
-
24
- def generate_graphs_for_authorities
25
- auths = authority_list_class.authorities_list
26
- generate_graphs_for_authority(authority_name: ALL_AUTH) # generates graph for all authorities
27
- auths.each { |authname| generate_graphs_for_authority(authority_name: authname) }
28
- end
29
-
30
- def generate_graphs_for_authority(authority_name:)
31
- [SEARCH, FETCH, ALL_ACTIONS].each_with_object({}) do |action, hash|
32
- hash[action] = generate_30_day_graph(authority_name: authority_name, action: action)
33
- end
34
- end
35
-
36
- def generate_30_day_graph(authority_name:, action:)
37
- # real expiration or force caught by cache_expired? So if we are here, either the cache has expired
38
- # or force was requested. We still expire the cache and use ttl to catch race conditions.
39
- Rails.cache.fetch(cache_key_for_authority_action(authority_name: authority_name, action: action),
40
- expires_in: next_expiry, race_condition_ttl: 1.hour, force: true) do
41
- data = graph_data_service.calculate_last_30_days(authority_name: authority_name, action: action)
42
- graphing_service.generate_daily_graph(authority_name: authority_name, action: action, data: data)
43
- data
44
- end
45
- end
46
-
47
- def cache_key_for_authority_action(authority_name:, action:)
48
- "#{PERFORMANCE_GRAPH_DAILY_DATA_CACHE_KEY}--#{authority_name}--#{action}"
49
- end
50
-
51
- def cache_key_for_force
52
- "#{PERFORMANCE_GRAPH_DAILY_DATA_CACHE_KEY}--force"
53
- end
54
-
55
- def next_expiry
56
- QaServer::CacheExpiryService.cache_expiry
57
- end
58
- end
59
- end
60
- end
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
- # Generate graphs for the past 24 hours using cached data. The last hour of data is always calculated and all graphs
3
- # for are generated.
4
- module QaServer
5
- class PerformanceHourlyGraphCache
6
- class_attribute :authority_list_class, :graph_data_service, :graphing_service
7
- self.authority_list_class = QaServer::AuthorityListerService
8
- self.graph_data_service = QaServer::PerformanceGraphDataService
9
- self.graphing_service = QaServer::PerformanceGraphingService
10
-
11
- class << self
12
- include QaServer::CacheKeys
13
- include QaServer::PerformanceHistoryDataKeys
14
-
15
- # Generates graphs for the past 24 hours for :search, :fetch, and :all actions for each authority.
16
- # @param force [Boolean] if true, run the tests even if the cache hasn't expired; otherwise, use cache if not expired
17
- def generate_graphs(force: false)
18
- QaServer.config.monitor_logger.debug("(QaServer::PerformanceHourlyGraphCache) - GENERATING hourly performance graphs (force: #{force})")
19
- QaServer.config.performance_cache.write_all
20
- generate_graphs_for_authorities(force: force)
21
- end
22
-
23
- private
24
-
25
- def generate_graphs_for_authorities(force:)
26
- auths = authority_list_class.authorities_list
27
- generate_graphs_for_authority(authority_name: ALL_AUTH, force: force) # generates graph for all authorities
28
- auths.each { |authname| generate_graphs_for_authority(authority_name: authname, force: force) }
29
- end
30
-
31
- def generate_graphs_for_authority(authority_name:, force:)
32
- [SEARCH, FETCH, ALL_ACTIONS].each_with_object({}) do |action, hash|
33
- hash[action] = generate_24_hour_graph(authority_name: authority_name, action: action, force: force)
34
- end
35
- end
36
-
37
- def generate_24_hour_graph(authority_name:, action:, force:)
38
- graph_created = false
39
- data = Rails.cache.fetch(cache_key_for_authority_action(authority_name: authority_name, action: action),
40
- expires_in: QaServer::TimeService.current_time.end_of_hour - QaServer::TimeService.current_time,
41
- race_condition_ttl: 1.hour, force: force) do
42
- data = graph_data_service.calculate_last_24_hours(authority_name: authority_name, action: action)
43
- graphing_service.generate_hourly_graph(authority_name: authority_name, action: action, data: data)
44
- graph_created = true
45
- data
46
- end
47
- regen_last_hour_and_graph(authority_name: authority_name, action: action, data: data) unless graph_created
48
- end
49
-
50
- def regen_last_hour_and_graph(authority_name:, action:, data:)
51
- Rails.cache.fetch(cache_key_for_authority_action(authority_name: authority_name, action: action),
52
- expires_in: QaServer::TimeService.current_time.end_of_hour - QaServer::TimeService.current_time,
53
- race_condition_ttl: 1.hour, force: true) do
54
- data = graph_data_service.recalculate_last_hour(authority_name: authority_name, action: action, averages: data)
55
- graphing_service.generate_hourly_graph(authority_name: authority_name, action: action, data: data)
56
- data
57
- end
58
- end
59
-
60
- def cache_key_for_authority_action(authority_name:, action:)
61
- "#{PERFORMANCE_GRAPH_HOURLY_DATA_CACHE_KEY}--#{authority_name}--#{action}"
62
- end
63
- end
64
- end
65
- end
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
- # Generate graphs for the past 12 months using cached data. Graphs are generated only if the cache has expired.
3
- module QaServer
4
- class PerformanceMonthlyGraphCache
5
- class_attribute :authority_list_class, :graph_data_service, :graphing_service
6
- self.authority_list_class = QaServer::AuthorityListerService
7
- self.graph_data_service = QaServer::PerformanceGraphDataService
8
- self.graphing_service = QaServer::PerformanceGraphingService
9
-
10
- class << self
11
- include QaServer::CacheKeys
12
- include QaServer::PerformanceHistoryDataKeys
13
-
14
- # Generates graphs for the past 30 days for :search, :fetch, and :all actions for each authority.
15
- # @param force [Boolean] if true, run the tests even if the cache hasn't expired; otherwise, use cache if not expired
16
- def generate_graphs(force: false)
17
- return unless QaServer::CacheExpiryService.cache_expired?(key: cache_key_for_force, force: force, next_expiry: next_expiry)
18
- QaServer.config.monitor_logger.debug("(QaServer::PerformanceMonthlyGraphCache) - GENERATING monthly performance graphs (force: #{force})")
19
- generate_graphs_for_authorities
20
- end
21
-
22
- private
23
-
24
- def generate_graphs_for_authorities
25
- auths = authority_list_class.authorities_list
26
- generate_graphs_for_authority(authority_name: ALL_AUTH) # generates graph for all authorities
27
- auths.each { |authname| generate_graphs_for_authority(authority_name: authname) }
28
- end
29
-
30
- def generate_graphs_for_authority(authority_name:)
31
- [SEARCH, FETCH, ALL_ACTIONS].each_with_object({}) do |action, hash|
32
- hash[action] = generate_12_month_graph(authority_name: authority_name, action: action)
33
- end
34
- end
35
-
36
- def generate_12_month_graph(authority_name:, action:)
37
- # real expiration or force caught by cache_expired? So if we are here, either the cache has expired
38
- # or force was requested. We still expire the cache and use ttl to catch race conditions.
39
- Rails.cache.fetch(cache_key_for_authority_action(authority_name: authority_name, action: action),
40
- expires_in: next_expiry, race_condition_ttl: 1.hour, force: true) do
41
- data = graph_data_service.calculate_last_12_months(authority_name: authority_name, action: action)
42
- graphing_service.generate_monthly_graph(authority_name: authority_name, action: action, data: data)
43
- data
44
- end
45
- end
46
-
47
- def cache_key_for_authority_action(authority_name:, action:)
48
- "#{PERFORMANCE_GRAPH_MONTHLY_DATA_CACHE_KEY}--#{authority_name}--#{action}"
49
- end
50
-
51
- def cache_key_for_force
52
- "#{PERFORMANCE_GRAPH_MONTHLY_DATA_CACHE_KEY}--force"
53
- end
54
-
55
- def next_expiry
56
- QaServer::CacheExpiryService.cache_expiry
57
- end
58
- end
59
- end
60
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'fileutils'
3
- require 'gruff'
4
-
5
- # This module include provides graph methods used by all monitor status presenters working with graphs
6
- module QaServer::MonitorStatus
7
- module GruffGraph
8
- private
9
-
10
- def graph_relative_path
11
- File.join('qa_server', 'charts')
12
- end
13
-
14
- def graph_full_path(graph_filename)
15
- path = Rails.root.join('app', 'assets', 'images', graph_relative_path)
16
- FileUtils.mkdir_p path
17
- File.join(path, graph_filename)
18
- end
19
- end
20
- end