Skip to content

Commit

Permalink
AP-5143: Remove Geckoboard notification files and gems
Browse files Browse the repository at this point in the history
  • Loading branch information
skdejong committed Nov 14, 2024
1 parent 5b2c3aa commit 211481b
Show file tree
Hide file tree
Showing 36 changed files with 5 additions and 1,052 deletions.
1 change: 0 additions & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ RSpec/AnyInstance:
- 'spec/services/ccms/submitters/obtain_applicant_reference_service_spec.rb'
- 'spec/services/ccms/submitters/obtain_case_reference_service_spec.rb'
- 'spec/services/ccms/submitters/obtain_document_id_service_spec.rb'
- 'spec/services/dashboard_event_handler_spec.rb'
- 'spec/services/metrics/send_metrics_spec.rb'
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ gem "active_model_serializers", "~> 0.10.14"
gem "csv"
gem "discard", "~> 1.4"
gem "faraday"
gem "geckoboard-ruby"
gem "google-apis-sheets_v4"
gem "govuk_notify_rails", "~> 3.0.0"
gem "net-imap"
Expand Down
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ GEM
ffi (1.17.0)
ffi (1.17.0-x86_64-darwin)
formatador (1.1.0)
geckoboard-ruby (0.4.0)
globalid (1.2.1)
activesupport (>= 6.1)
google-apis-core (0.15.1)
Expand Down Expand Up @@ -788,7 +787,6 @@ DEPENDENCIES
factory_bot_rails (>= 6.2.0)
faker (>= 1.9.1)
faraday
geckoboard-ruby
google-apis-sheets_v4
govuk-components
govuk_design_system_formbuilder
Expand Down
37 changes: 0 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ The laa-apply-for-legal-aid system is a web service for solicitors that provide
- [True Layer](#true-layer)
- [**Check Financial Eligibility Service**](#check-financial-eligibility-service)
- [**Legal Framework API Service**](#legal-framework-api-service)
- [**Geckoboard Dashboard**](#geckoboard-dashboard)
- [1. Create a widget data provider](#1-create-a-widget-data-provider)
- [2. Add a cronjob to run it](#2-add-a-cronjob-to-run-it)
- [3. Add the widget to the Geckoboard dashboard](#3-add-the-widget-to-the-geckoboard-dashboard)
- [**Troubleshooting**](#troubleshooting)
- [**Maintenance mode**](#docs/maintenance_mode.md)

Expand Down Expand Up @@ -468,39 +464,6 @@ The URL for this service should be set using the environment variable `CFE_CIVIL

The URL for this service should be set using the environment variable `LEGAL_FRAMEWORK_API_HOST`.

---

## Geckoboard Dashboard

Several sets of statistics are exported to Geckoboard for displaying on an application dashboard.

### How to add a new widget to the dashboard

There are three steps to creating a new widget for the Geckoboard dashboard

### 1. Create a widget data provider

Create a new class in the `app/models/dashboard/widget_data_providers` directory. This should define three class methods:

* `.handle` - the name of the widget, which will be qualified with a project name and environment. For example `my_widget` would become `apply_for_legal_aid.production.my_widget` in the list of datasets on Geckoboard
* `.dataset_defintion` - the list of fields that will be in the dataset (see https://developer.geckoboard.com/hc/en-us/sections/360002865451-Getting-started for details on how to define and provide data for a dataset.)
* `.data` - the actual data that will be sent to Geckoboard every time it is run.

This data provider will be used by the `Dashboard::Widget` class when called with the name of the data provider as a parameter.

### 2. Add a cronjob to run it

Create a yaml configuration file for each cronjob under `./helm_deploy/apply_for_legal_aid/templates` by copying the `.dashboard_template_cron.yaml.sample` file and configure it to run the command `rake job:dashboard:update[the WidgetDataProvider class name here]` with
your chosen cron job schedule.

### 3. Add the widget to the Geckoboard dashboard

Once the job has been run at least once, you will be able to select the dataset as a data source when adding a new widget.

----



## Troubleshooting

Refer to the specific [README](./docs/troubleshooting.md)
5 changes: 0 additions & 5 deletions app/controllers/admin/user_dashboard_controller.rb

This file was deleted.

11 changes: 0 additions & 11 deletions app/jobs/dashboard/suspendable_job.rb

This file was deleted.

12 changes: 0 additions & 12 deletions app/jobs/dashboard/updater_job.rb

This file was deleted.

16 changes: 4 additions & 12 deletions app/lib/alert_manager.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class AlertManager
class << self
def capture_exception(exception)
return unless sendable?(exception)
return unless sendable?

alert_klass.capture_exception(exception)
end

def capture_message(message)
return unless sendable?(message)
return unless sendable?

alert_klass.capture_message(message)
end
Expand All @@ -16,20 +16,12 @@ def alert_klass
Setting.setting.alert_via_sentry? ? Sentry : SlackAlerter
end

def sendable?(message_or_exception)
def sendable?
return false unless HostEnv.environment.in?(%i[production uat staging])

return false if geckoboard_too_many_messages_error?(message_or_exception)

true
end

def geckoboard_too_many_messages_error?(exception)
return true if exception.is_a?(Geckoboard::UnexpectedStatusError) && exception.message =~ /^You have exceeded the API rate limit/

false
end
end

private_class_method :alert_klass, :sendable?, :geckoboard_too_many_messages_error?
private_class_method :alert_klass, :sendable?
end
4 changes: 0 additions & 4 deletions app/models/ccms/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ class Submission < ApplicationRecord
validates :legal_aid_application_id, presence: true
# rubocop:enable Rails/RedundantPresenceValidationOnBelongsTo

after_save do
ActiveSupport::Notifications.instrument "dashboard.ccms_submission_saved", id:, state: aasm_state
end

POLL_LIMIT = Rails.env.development? ? 99 : 20

STATE_SERVICES = {
Expand Down
38 changes: 0 additions & 38 deletions app/models/dashboard/widget.rb

This file was deleted.

86 changes: 0 additions & 86 deletions app/models/dashboard/widget_data_providers/applications.rb

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions app/models/firm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ class Firm < ApplicationRecord
has_many :actor_permissions, as: :permittable
has_many :permissions, through: :actor_permissions

after_create do
ActiveSupport::Notifications.instrument "dashboard.firm_created"
end

def self.search(search_term)
if search_term
where("name ILIKE ?", "%#{search_term}%")
Expand Down
Loading

0 comments on commit 211481b

Please sign in to comment.