Skip to content

Commit fa34024

Browse files
committed
Add rake task to export form counts to CloudWatch
Provides metrics:export_form_counts for scheduled publishing of form count metrics via FormCountService.
1 parent 9e92f4b commit fa34024

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

lib/tasks/metrics.rake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace :metrics do
2+
desc "Export form counts to CloudWatch metrics grouped by organisation and state"
3+
task export_form_counts: :environment do
4+
Metrics::FormCountService.new.publish_form_counts
5+
end
6+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require "rails_helper"
2+
3+
RSpec.describe "metrics.rake", type: :task do
4+
describe "metrics:export_form_counts" do
5+
subject(:task) do
6+
Rake::Task["metrics:export_form_counts"]
7+
end
8+
9+
it "publishes form counts via Metrics::FormCountService" do
10+
service = instance_double(Metrics::FormCountService)
11+
allow(Metrics::FormCountService).to receive(:new).and_return(service)
12+
expect(service).to receive(:publish_form_counts)
13+
14+
task.invoke
15+
end
16+
end
17+
end

0 commit comments

Comments
 (0)