Skip to content

Commit

Permalink
APPEALS-57508: Correspondence Details Serializers Contain Unnecessary…
Browse files Browse the repository at this point in the history
… Information (#22937)

* filtered related correspondece values

* added new correspondence_details serializer

* created new appeal serializer and updated frontend to handle new values

* added correspondence type to serializer

* fixed bug where appeal id was not matching with previously linked appeals

* fixed failing test

* fixed failing tests
  • Loading branch information
HunJerBAH authored Sep 27, 2024
1 parent c0b3b90 commit 565a2fe
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 34 deletions.
14 changes: 8 additions & 6 deletions app/controllers/correspondence_details_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,13 @@ def sort_response_letters(response_letters)
end

def appeals
case_search_results = CaseSearchResultsForCaseflowVeteranId.new(
caseflow_veteran_ids: [@correspondence.veteran_id], user: current_user
).search_call
appeals = Appeal.where(veteran_file_number: @correspondence.veteran.file_number)

{ appeals_information: case_search_results.extra[:case_search_results] }
serialized_appeals = appeals.map do |appeal|
WorkQueue::CorrespondenceDetailsAppealSerializer.new(appeal).serializable_hash[:data][:attributes]
end

{ appeals_information: serialized_appeals }
end

def mail_tasks
Expand All @@ -190,7 +192,7 @@ def serialized_correspondences
end

def serialized_data
serializer = WorkQueue::CorrespondenceSerializer.new(ordered_correspondences)
serializer = WorkQueue::CorrespondenceDetailsSerializer.new(ordered_correspondences)
serializer.serializable_hash[:data]
end

Expand All @@ -202,7 +204,7 @@ def prior_mail
prior_mail = Correspondence.prior_mail(veteran_by_correspondence.id, correspondence.uuid).order(:va_date_of_receipt)
.select { |corr| corr.status == "Completed" || corr.status == "Pending" }
serialized_mail = prior_mail.map do |correspondence|
WorkQueue::CorrespondenceSerializer.new(correspondence).serializable_hash[:data][:attributes]
WorkQueue::CorrespondenceDetailsSerializer.new(correspondence).serializable_hash[:data][:attributes]
end

{ prior_mail: serialized_mail }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class WorkQueue::CorrespondenceAppealsSerializer

set_key_transform :camel_lower

attribute :id
attribute :id, &:appeal_id
attribute :correspondences_appeals_tasks
attribute :docket_number do |object|
object.appeal.docket_number
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# frozen_string_literal: true

class WorkQueue::CorrespondenceDetailsAppealSerializer
include FastJsonapi::ObjectSerializer

set_key_transform :camel_lower

attribute :id
attribute :external_id, &:uuid
attribute :docket_name
attribute :docket_number
attribute :decision_date
attribute :overtime, &:overtime?
attribute :withdrawn, &:withdrawn?
attribute :status
attribute :case_type, &:type
attribute :aod, &:advanced_on_docket?
attribute :appellant_full_name do |object|
object.claimant&.name
end

attribute :veteran_full_name do |object|
object.veteran ? object.veteran.name.formatted(:readable_full) : "Cannot locate"
end

# count values pulled from WorkQueue::AppealSerializer issue attribute
attribute :issue_count do |object|
object.request_issues.active_or_decided_or_withdrawn.includes(:remand_reasons).count
end

attribute :assigned_to_location do |object, params|
if object&.status&.status == :distributed_to_judge
if params[:user]&.judge? || params[:user]&.attorney? || User.list_hearing_coordinators.include?(params[:user])
object.assigned_to_location
end
else
object.assigned_to_location
end
end

# badges attributes
attribute :veteran_appellant_deceased, &:veteran_appellant_deceased?
attribute :contested_claim, &:contested_claim?
attribute :mst, &:mst?
attribute :pact, &:pact?
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

class WorkQueue::CorrespondenceDetailsSerializer
include FastJsonapi::ObjectSerializer

set_key_transform :camel_lower

attribute :uuid
attribute :id
attribute :notes
attribute :va_date_of_receipt
attribute :nod
attribute :status
attribute :type
attribute :veteran_id
attribute :correspondence_type do |object|
object.correspondence_type&.name
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ class WorkQueue::CorrespondenceSerializer
object.veteran&.file_number
end

attribute :correspondence_appeal_ids do |object|
object.appeal_ids.map(&:to_s)
end
attribute :correspondence_appeal_ids, &:appeal_ids

attribute :correspondence_response_letters do |object|
object.correspondence_response_letters.map do |response_letter|
Expand Down
20 changes: 2 additions & 18 deletions client/app/queue/correspondence/details/CorrespondenceDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
import CorrespondenceResponseLetters from './CorrespondenceResponseLetters';
import COPY from '../../../../COPY';
import CaseListTable from 'app/queue/CaseListTable';
import { prepareAppealForSearchStore } from 'app/queue/utils';
import CorrespondenceTasksAdded from '../CorrespondenceTasksAdded';
import moment from 'moment';
import Pagination from 'app/components/Pagination/Pagination';
Expand Down Expand Up @@ -304,14 +303,11 @@ const CorrespondenceDetails = (props) => {
setDisableSubmitButton(buttonDisable);
}, [selectedAppeals]);

let appeals;

const sortAppeals = (selectedList) => {
appeals = [];
let filteredAppeals = [];
let unfilteredAppeals = [];

correspondence.appeals_information.appeals.map((appeal) => {
correspondence.appeals_information.map((appeal) => {
if (selectedList?.includes(appeal.id)) {
filteredAppeals.push(appeal);
} else {
Expand All @@ -325,19 +321,8 @@ const CorrespondenceDetails = (props) => {
unfilteredAppeals = unfilteredAppeals.sort((leftAppeal, rightAppeal) => leftAppeal.id - rightAppeal.id);

const sortedAppeals = filteredAppeals.concat(unfilteredAppeals);
const searchStoreAppeal = prepareAppealForSearchStore(sortedAppeals);
const appeall = searchStoreAppeal.appeals;
const appealldetail = searchStoreAppeal.appealDetails;
const hashKeys = Object.keys(appeall);

hashKeys.map((key) => {
const combinedHash = { ...appeall[key], ...appealldetail[key] };

appeals.push(combinedHash);

return true;
});
setAppealsToDisplay(appeals);
setAppealsToDisplay(sortedAppeals);
};

useEffect(() => {
Expand Down Expand Up @@ -810,7 +795,6 @@ CorrespondenceDetails.propTypes = {
organizations: PropTypes.array,
userCssId: PropTypes.string,
enableTopPagination: PropTypes.bool,
correspondence_appeal_ids: PropTypes.bool,
isInboundOpsUser: PropTypes.bool,
tasksUnrelatedToAppealEmpty: PropTypes.bool,
isInboundOpsSuperuser: PropTypes.bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ let props = {
}
],

appeals_information: {
appeals: [
appeals_information:
[
{
id: 1,
type: 'Correspondence',
Expand All @@ -288,8 +288,7 @@ let props = {
}
}
],
claim_reviews: []
}
claim_reviews: []
}
};

Expand Down Expand Up @@ -460,6 +459,7 @@ describe('CorrespondenceDetails', () => {

fireEvent.click(associatedPriorMailTab);
const checkbox = screen.getByRole('checkbox', { name: '1' });

fireEvent.click(checkbox);

// Mock API call
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/correspondence_details_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
let!(:current_user) { create(:inbound_ops_team_supervisor) }
let(:veteran) { create(:veteran) }
let!(:correspondence) { create(:correspondence, :with_correspondence_intake_task, assigned_to: current_user) }
let!(:appeal1) { create(:appeal) }
let!(:appeal2) { create(:appeal) }
let!(:appeal1) { create(:appeal, veteran_file_number: veteran.file_number) }
let!(:appeal2) { create(:appeal, veteran_file_number: veteran.file_number) }

before :each do
Fakes::Initializer.load!
Expand Down

0 comments on commit 565a2fe

Please sign in to comment.