Skip to content

Commit

Permalink
97 Added database table and endpoint for average number of days for c…
Browse files Browse the repository at this point in the history
…ompletion (#16313)

* 97 Added database table and endpoint for average number of days for claim completion.

* 97 Added SPEC file for unittest coverage and also linted everything.

* 97 Updated CODEOWNERS file.

* 97 Missed the spec at the end of the spec file in CODEOWNERS.

* 97 Updated test name to be reflective of what we are expecting.

---------

Co-authored-by: Rebecca Tolmach <[email protected]>
Co-authored-by: bmatos312 <[email protected]>
  • Loading branch information
3 people authored Apr 15, 2024
1 parent 9fbe39d commit 0234cb7
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ app/controllers/v0/appeals_controller.rb @department-of-veterans-affairs/benefit
app/controllers/v0/appointments_controller.rb @department-of-veterans-affairs/vfs-vaos @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v0/apps_controller.rb @department-of-veterans-affairs/lighthouse-pivot
app/controllers/v0/ask_va @department-of-veterans-affairs/ask-va-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v0/average_days_for_claim_completion_controller.rb @department-of-veterans-affairs/benefits-microservices @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v0/backend_statuses_controller.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v0/benefits_claims_controller.rb @department-of-veterans-affairs/benefits-management-tools-be @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v0/benefits_documents_controller.rb @department-of-veterans-affairs/benefits-management-tools-be @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down Expand Up @@ -194,6 +195,7 @@ app/models/async_transaction/base.rb @department-of-veterans-affairs/vfs-authent
app/models/async_transaction/va_profile @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/backend-review-group
app/models/async_transaction/vet360 @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/backend-review-group
app/models/attachment.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/models/average_days_for_claim_completion.rb @department-of-veterans-affairs/benefits-microservices @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/models/backend_status.rb @department-of-veterans-affairs/backend-review-group
app/models/bank_name.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/models/base_facility.rb @department-of-veterans-affairs/vfs-facilities-frontend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down Expand Up @@ -995,6 +997,7 @@ spec/controllers/sign_in @department-of-veterans-affairs/octo-identity
spec/controllers/v0/account_controls_controller_spec.rb @department-of-veterans-affairs/octo-identity
spec/controllers/v0/apps_controller_spec.rb @department-of-veterans-affairs/lighthouse-pivot
spec/controllers/v0/ask_va @department-of-veterans-affairs/ask-va-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/controllers/v0/average_days_for_claim_completion_controller_spec.rb @department-of-veterans-affairs/benefits-microservices @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/controllers/v0/benefits_claims_controller_spec.rb @department-of-veterans-affairs/benefits-management-tools-be @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/controllers/v0/benefits_reference_data_controller_spec.rb @department-of-veterans-affairs/Benefits-Team-1 @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/controllers/v0/burial_claims_controller_spec.rb @department-of-veterans-affairs/mbs-core-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down
15 changes: 15 additions & 0 deletions app/controllers/v0/average_days_for_claim_completion_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module V0
class AverageDaysForClaimCompletionController < ApplicationController
service_tag 'average-days-to-completion'
skip_before_action :authenticate, only: :index

def index
rtn = AverageDaysForClaimCompletion.order('created_at DESC').first
render json: {
average_days: rtn.present? ? rtn.average_days : -1.0
}
end
end
end
4 changes: 4 additions & 0 deletions app/models/average_days_for_claim_completion.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

class AverageDaysForClaimCompletion < ApplicationRecord
end
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@
get 'claim_letters', to: 'claim_letters#index'
get 'claim_letters/:document_id', to: 'claim_letters#show'

get 'average_days_for_claim_completion', to: 'average_days_for_claim_completion#index'

get 'virtual_agent_claim_letters', to: 'virtual_agent_claim_letters#index'
get 'virtual_agent_claim_letters/:document_id', to: 'virtual_agent_claim_letters#show'

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe V0::AverageDaysForClaimCompletionController, type: :controller do
context 'when querying with nothing in db' do
it 'returns -1 for value' do
get :index
expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['average_days']).to eq(-1.0)
end
end

context 'when querying with record in db' do
before do
AverageDaysForClaimCompletion.create(average_days: 100)
end

it 'returns the value' do
get :index
expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['average_days']).to eq(100.0)
end
end

context 'when querying with multiple records in db' do
before do
AverageDaysForClaimCompletion.create(average_days: 100)
AverageDaysForClaimCompletion.create(average_days: 200)
AverageDaysForClaimCompletion.create(average_days: 300)
end

it 'returns the most recently inserted value' do
get :index
expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['average_days']).to eq(300.0)
end
end
end

0 comments on commit 0234cb7

Please sign in to comment.