Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APPEALS-57508: Correspondence Details Serializers Contain Unnecessary Information #22937

Merged
merged 12 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
HunJerBAH marked this conversation as resolved.
Show resolved Hide resolved
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left badge attributes in so they can display in the table.

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
HunJerBAH marked this conversation as resolved.
Show resolved Hide resolved

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 @@ -254,14 +253,11 @@ const CorrespondenceDetails = (props) => {
return checked ? userAccess !== 'admin_access' : false;
};

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 @@ -275,19 +271,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);
HunJerBAH marked this conversation as resolved.
Show resolved Hide resolved
setAppealsToDisplay(sortedAppeals);
};

useEffect(() => {
Expand Down Expand Up @@ -743,7 +728,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
Loading