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

progress pr - Batch requests in task table #10382

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
9bc9d2b
remove document count to batched structure
Apr 9, 2019
5832a6c
Save work so far
Apr 9, 2019
20c6886
progress ...
Apr 9, 2019
1820b34
more progress...
Apr 9, 2019
a53c16b
send all tasks
Apr 9, 2019
7888f58
combine tasks
Apr 9, 2019
7b4327e
finish batching of document count requests
Apr 10, 2019
2295090
Merge branch 'master' into Batch-Requests-In-Task-Table
youngfreezyVA Apr 10, 2019
5da1984
remove require
Apr 10, 2019
6be8cb7
lint issues
Apr 10, 2019
6f09feb
code climate fix?
Apr 10, 2019
dee6d10
code climate fix?
Apr 10, 2019
7b990e7
code climate fix?
Apr 10, 2019
a5f225f
remove statement and remove failing test since doc counts are now loa…
Apr 10, 2019
b9b01a7
fix last code climate issue :-/
Apr 10, 2019
96fbe7d
rename route
Apr 10, 2019
2d86815
code climate is getting annoying
Apr 10, 2019
13a2d95
comment out test for now
Apr 10, 2019
04243d5
comment out test for now
Apr 10, 2019
a4e8390
update request with proper endpoint
Apr 10, 2019
5ef9f7f
Merge branch 'master' into Batch-Requests-In-Task-Table
Apr 10, 2019
3c0818d
fix routes file
Apr 10, 2019
ae8dfc7
apply changes to colocated task list view
Apr 10, 2019
bbc0dde
DRY
Apr 10, 2019
d45b30b
DRY2
Apr 10, 2019
72032d3
add new hearings_by_id route
Apr 10, 2019
5ab747f
get hearing badge working, dry next
Apr 10, 2019
99815bc
DRY
Apr 10, 2019
9ba40d3
lint issues
Apr 10, 2019
33ffdf0
break down method to avoid complexity
Apr 10, 2019
0324916
Merge branch 'master' into Batch-Requests-In-Task-Table
youngfreezyVA Apr 10, 2019
04ff281
code climate
Apr 10, 2019
9306411
lint issues
Apr 10, 2019
1d98573
try to fix codeclimate warning
Apr 11, 2019
fb5d19f
Merge branch 'master' into Batch-Requests-In-Task-Table
Apr 11, 2019
c6382eb
move hearing object mapping to HearingMapper class
Apr 11, 2019
a79f670
rename variables for clarity, move building of obj to hearing_repository
Apr 11, 2019
8f0a5f8
remove duplicate code, add lint fixes
Apr 11, 2019
51046ec
linting issues and handle error on appeal basis
Apr 11, 2019
173680f
Merge branch 'master' into Batch-Requests-In-Task-Table
youngfreezyVA Apr 11, 2019
9259010
handle error in another function
Apr 11, 2019
18f6248
make changes to reducer based on multiple requests
Apr 11, 2019
08cdcd9
lint
Apr 11, 2019
d02d002
Merge branch 'master' into Batch-Requests-In-Task-Table
Apr 11, 2019
a85a37a
code climate man
Apr 11, 2019
b4acfad
lint
Apr 11, 2019
d669c06
non happy path
Apr 11, 2019
b16c1aa
lint
Apr 11, 2019
ca38094
Merge branch 'master' into Batch-Requests-In-Task-Table
youngfreezyVA Apr 11, 2019
90d8e63
Merge branch 'master' of https://github.com/department-of-veterans-af…
Apr 11, 2019
ffc9df5
fix one code climate issue
Apr 11, 2019
c39ab29
Merge branch 'Batch-Requests-In-Task-Table' of https://github.com/dep…
Apr 11, 2019
767b959
Merge branch 'master' into Batch-Requests-In-Task-Table
youngfreezyVA Apr 12, 2019
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
65 changes: 41 additions & 24 deletions app/controllers/appeals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,24 @@ def show_case_list
end
end

def document_count
render json: { document_count: appeal.number_of_documents }
rescue Caseflow::Error::EfolderAccessForbidden => e
render(e.serialize_response)
rescue StandardError => e
handle_non_critical_error("document_count", e)
def document_counts_by_id
render json: { document_counts_by_id: build_document_counts_hash({}) }
rescue Caseflow::Error::EfolderAccessForbidden => error
render(error.serialize_response)
youngfreezyVA marked this conversation as resolved.
Show resolved Hide resolved
end

def build_document_counts_hash(document_counts_by_id_hash)
params[:appeal_ids].split(",").each do |appeal_id|
begin
document_counts_by_id_hash[appeal_id] =
Appeal.find_appeal_by_id_or_find_or_create_legacy_appeal_by_vacols_id(appeal_id)
.number_of_documents
rescue StandardError => error
document_counts_by_id_hash[appeal_id] = error
next
end
end
document_counts_by_id_hash
end

def power_of_attorney
Expand All @@ -50,26 +62,31 @@ def power_of_attorney
}
end

def hearings
def hearings_by_id
log_hearings_request

most_recently_held_hearing = appeal.hearings
.select { |hearing| hearing.disposition.to_s == Constants.HEARING_DISPOSITION_TYPES.held }
.max_by(&:scheduled_for)

render json:
if most_recently_held_hearing
{
held_by: most_recently_held_hearing.judge.present? ? most_recently_held_hearing.judge.full_name : "",
viewed_by_judge: !most_recently_held_hearing.hearing_views.empty?,
date: most_recently_held_hearing.scheduled_for,
type: most_recently_held_hearing.readable_request_type,
external_id: most_recently_held_hearing.external_id,
disposition: most_recently_held_hearing.disposition
}
else
{}
render json: { most_recently_held_hearings_by_id: build_most_recently_held_hearings_hash }
end

def build_most_recently_held_hearings_hash
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@monfresh same here

Copy link
Contributor

Choose a reason for hiding this comment

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

I will take a look

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there's going to be alot of changes to this, so please hold off for now i'll reach back out when its ready if i'm still facing this issue, thank you!

most_recently_held_hearings_by_id_hash = {}
params[:appeal_ids].split(",").each do |appeal_id|
begin
most_recently_held_hearings_by_id_hash[appeal_id] = HearingRepository
.build_hearing_object_for_appeal(most_recently_held_hearing(appeal_id))
rescue StandardError => error
most_recently_held_hearings_by_id_hash[appeal_id] = error
next
end
end
most_recently_held_hearings_by_id_hash
end

def most_recently_held_hearing(appeal_id)
@most_recently_held_hearing =
Appeal.find_appeal_by_id_or_find_or_create_legacy_appeal_by_vacols_id(appeal_id)
.hearings
.select { |hearing| hearing.disposition.to_s == Constants.HEARING_DISPOSITION_TYPES.held }
.max_by(&:scheduled_for)
end

# For legacy appeals, veteran address and birth/death dates are
Expand Down
11 changes: 11 additions & 0 deletions app/repositories/hearing_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ def fetch_hearings_for_judge(css_id, is_fetching_issues = false)
hearings
end

def build_hearing_object_for_appeal(hearing)
{
held_by: hearing&.judge.present? ? hearing.judge.full_name : "",
viewed_by_judge: hearing && !hearing.hearing_views.empty?,
date: hearing&.scheduled_for,
type: hearing&.readable_request_type,
external_id: hearing&.external_id,
disposition: hearing&.disposition
}
end

def fetch_hearings_for_parent(hearing_day_id)
# Implemented by call the array version of this method
fetch_hearings_for_parents([hearing_day_id]).values.first || []
Expand Down
51 changes: 11 additions & 40 deletions client/app/queue/AppealDocumentCount.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import PropTypes from 'prop-types';
import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';

import ApiUtil from '../util/ApiUtil';
import _ from 'lodash';

import { loadAppealDocCount, setAppealDocCount, errorFetchingDocumentCount } from './QueueActions';

Expand All @@ -15,48 +14,20 @@ const documentCountStyling = css({
});

class AppealDocumentCount extends React.PureComponent {
componentDidMount = () => {
const {
appeal,
docCountForAppeal
} = this.props;

if (appeal.isPaperCase) {
return;
}

if (docCountForAppeal && docCountForAppeal.docCount) {
return;
}

const requestOptions = {
withCredentials: true,
timeout: { response: 5 * 60 * 1000 }
};

this.props.loadAppealDocCount(this.props.externalId);

ApiUtil.get(`/appeals/${this.props.externalId}/document_count`, requestOptions).then((response) => {
const resp = JSON.parse(response.text);

this.props.setAppealDocCount(this.props.externalId, resp.document_count);
}, () => {
this.props.errorFetchingDocumentCount(this.props.externalId);
});
}

render = () => {
const {
docCountForAppeal,
loadingText
docCountsByAppealId,
loadingText,
externalId
} = this.props;
const isLoadingOrError = loadingText && (docCountsByAppealId.loading || docCountsByAppealId.error);

if (docCountForAppeal) {
if (docCountForAppeal.docCount) {
return docCountForAppeal.docCount;
} else if (loadingText && (docCountForAppeal.loading || docCountForAppeal.error)) {
return docCountForAppeal.error || <span {...documentCountStyling}>Loading number of docs...</span>;
if (!_.isEmpty(docCountsByAppealId)) {
if (isLoadingOrError) {
return docCountsByAppealId.error || <span {...documentCountStyling}>Loading number of docs...</span>;
}

return docCountsByAppealId[externalId] || null;
}

return null;
Expand All @@ -73,7 +44,7 @@ const mapStateToProps = (state, ownProps) => {

return {
externalId,
docCountForAppeal: state.queue.docCountForAppeal[externalId] || null
docCountsByAppealId: state.queue.docCountsByAppealId
};
};

Expand Down
15 changes: 13 additions & 2 deletions client/app/queue/AttorneyTaskListView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import QueueOrganizationDropdown from './components/QueueOrganizationDropdown';
import AppSegment from '@department-of-veterans-affairs/caseflow-frontend-toolkit/components/AppSegment';
import Link from '@department-of-veterans-affairs/caseflow-frontend-toolkit/components/Link';
import Alert from '../components/Alert';
import { batchDocCountRequests, batchHearingBadgeRequests } from '../util/ApiUtil';
import { loadAppealDocCount, setAppealDocCount,
errorFetchingDocumentCount, setMostRecentlyHeldHearingForAppeals } from './QueueActions';

import {
completeTasksByAssigneeCssIdSelector,
Expand Down Expand Up @@ -43,15 +46,19 @@ class AttorneyTaskListView extends React.PureComponent {
componentDidMount = () => {
this.props.clearCaseSelectSearch();
this.props.resetErrorMessages();
const combinedTasks = [...this.props.workableTasks, ...this.props.onHoldTasks, ...this.props.completedTasks];

if (_.some(
[...this.props.workableTasks, ...this.props.onHoldTasks, ...this.props.completedTasks],
combinedTasks,
(task) => !task.taskId)) {
this.props.showErrorMessage({
title: COPY.TASKS_NEED_ASSIGNMENT_ERROR_TITLE,
detail: COPY.TASKS_NEED_ASSIGNMENT_ERROR_MESSAGE
});
}
batchDocCountRequests(this.props, combinedTasks);
batchHearingBadgeRequests(this.props, combinedTasks);

};

render = () => {
Expand Down Expand Up @@ -141,7 +148,11 @@ const mapDispatchToProps = (dispatch) => ({
resetErrorMessages,
resetSuccessMessages,
resetSaveState,
showErrorMessage
showErrorMessage,
loadAppealDocCount,
setAppealDocCount,
errorFetchingDocumentCount,
setMostRecentlyHeldHearingForAppeals
}, dispatch)
});

Expand Down
24 changes: 21 additions & 3 deletions client/app/queue/ColocatedTaskListView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,20 @@ import {

import Alert from '../components/Alert';
import TabWindow from '../components/TabWindow';
import { batchDocCountRequests, batchHearingBadgeRequests } from '../util/ApiUtil';
import { loadAppealDocCount, setAppealDocCount,
errorFetchingDocumentCount, setMostRecentlyHeldHearingForAppeals } from './QueueActions';

const containerStyles = css({
position: 'relative'
});

class ColocatedTaskListView extends React.PureComponent {
componentDidMount = () => {

this.props.clearCaseSelectSearch();
batchDocCountRequests(this.props, this.props.combinedTasks);
batchHearingBadgeRequests(this.props, this.props.combinedTasks);
};

componentWillUnmount = () => this.props.hideSuccessMessage();
Expand Down Expand Up @@ -69,18 +75,30 @@ class ColocatedTaskListView extends React.PureComponent {

const mapStateToProps = (state) => {
const { success } = state.ui.messages;
const newTasks = newTasksByAssigneeCssIdSelector(state);
const onHoldTasks = onHoldTasksByAssigneeCssIdSelector(state);
const completedTasks = completeTasksByAssigneeCssIdSelector(state);

return {
success,
organizations: state.ui.organizations,
numNewTasks: newTasksByAssigneeCssIdSelector(state).length,
numOnHoldTasks: onHoldTasksByAssigneeCssIdSelector(state).length
numNewTasks: newTasks.length,
numOnHoldTasks: onHoldTasks.length,
combinedTasks: [
...newTasks,
...onHoldTasks,
...completedTasks
]
};
};

const mapDispatchToProps = (dispatch) => bindActionCreators({
clearCaseSelectSearch,
hideSuccessMessage
hideSuccessMessage,
loadAppealDocCount,
setAppealDocCount,
errorFetchingDocumentCount,
setMostRecentlyHeldHearingForAppeals
}, dispatch);

export default (connect(mapStateToProps, mapDispatchToProps)(ColocatedTaskListView));
Expand Down
6 changes: 5 additions & 1 deletion client/app/queue/JudgeDecisionReviewTaskListView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import { judgeDecisionReviewTasksSelector } from './selectors';

import { fullWidth } from './constants';
import COPY from '../../COPY.json';
import { setMostRecentlyHeldHearingForAppeals } from './QueueActions';
import { batchHearingBadgeRequests } from '../util/ApiUtil';

const containerStyles = css({
position: 'relative'
Expand All @@ -36,6 +38,7 @@ class JudgeDecisionReviewTaskListView extends React.PureComponent {
componentDidMount = () => {
this.props.clearCaseSelectSearch();
this.props.resetErrorMessages();
batchHearingBadgeRequests(this.props, this.props.tasks);
};

render = () => {
Expand Down Expand Up @@ -102,7 +105,8 @@ const mapDispatchToProps = (dispatch) => (
clearCaseSelectSearch,
resetErrorMessages,
resetSuccessMessages,
resetSaveState
resetSaveState,
setMostRecentlyHeldHearingForAppeals
}, dispatch)
);

Expand Down
15 changes: 7 additions & 8 deletions client/app/queue/QueueActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { associateTasksWithAppeals,
prepareAllTasksForStore,
extractAppealsAndAmaTasks,
prepareMostRecentlyHeldHearingForStore,
prepareMostRecentlyHeldHearingsForStore,
prepareTasksForStore } from './utils';
import { ACTIONS } from './constants';
import { hideErrorMessage, showErrorMessage, showSuccessMessage } from './uiReducer/uiActions';
Expand Down Expand Up @@ -145,11 +145,11 @@ export const getNewDocumentsForTask = (taskId) => (dispatch) => {
});
};

export const loadAppealDocCount = (appealId) => (dispatch) => {
export const loadAppealDocCount = (appealIds) => (dispatch) => {
dispatch({
type: ACTIONS.STARTED_DOC_COUNT_REQUEST,
payload: {
appealId
appealIds
}
});
};
Expand Down Expand Up @@ -185,17 +185,16 @@ export const getAppealValue = (appealId, endpoint, name) => (dispatch) => {
});
};

export const setAppealDocCount = (appealId, docCount) => ({
export const setAppealDocCount = (docCountsByAppealId) => ({
type: ACTIONS.SET_APPEAL_DOC_COUNT,
payload: {
appealId,
docCount
docCountsByAppealId
}
});

export const setMostRecentlyHeldHearingForAppeal = (appealId, hearing) => ({
export const setMostRecentlyHeldHearingForAppeals = (mostRecentlyHeldHearingsById) => ({
type: ACTIONS.SET_MOST_RECENTLY_HELD_HEARING_FOR_APPEAL,
payload: prepareMostRecentlyHeldHearingForStore(appealId, hearing)
payload: prepareMostRecentlyHeldHearingsForStore(mostRecentlyHeldHearingsById)
});

export const setDecisionOptions = (opts) => (dispatch) => {
Expand Down
24 changes: 7 additions & 17 deletions client/app/queue/components/HearingBadge.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ import { css } from 'glamor';
import _ from 'lodash';
import * as React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';

import Tooltip from '../../components/Tooltip';
import { COLORS } from '../../constants/AppConstants';

import ApiUtil from '../../util/ApiUtil';
import { DateString } from '../../util/DateUtil';
import { setMostRecentlyHeldHearingForAppeal } from '../QueueActions';

/**
* This component can accept either a Hearing object or a Task object.
Expand Down Expand Up @@ -43,16 +40,13 @@ const listStyling = css({
});

class HearingBadge extends React.PureComponent {
componentDidMount = () => {
if (!this.props.mostRecentlyHeldHearingForAppeal && !this.props.hearing && this.props.externalId) {
ApiUtil.get(`/appeals/${this.props.externalId}/hearings`).then((response) => {
this.props.setMostRecentlyHeldHearingForAppeal(this.props.externalId, JSON.parse(response.text));
});
}
}

render = () => {
const hearing = this.props.mostRecentlyHeldHearingForAppeal || this.props.hearing;
const { externalId, mostRecentlyHeldHearingsById } = this.props;

const hearing =
mostRecentlyHeldHearingsById.filter((hearingObj) => hearingObj.appealId === externalId)[0] ||
this.props.hearing;

if (!hearing || !hearing.date) {
return null;
Expand Down Expand Up @@ -93,12 +87,8 @@ const mapStateToProps = (state, ownProps) => {
return {
hearing,
externalId,
mostRecentlyHeldHearingForAppeal: state.queue.mostRecentlyHeldHearingForAppeal[externalId] || null
mostRecentlyHeldHearingsById: state.queue.mostRecentlyHeldHearingsById
};
};

const mapDispatchToProps = (dispatch) => bindActionCreators({
setMostRecentlyHeldHearingForAppeal
}, dispatch);

export default connect(mapStateToProps, mapDispatchToProps)(HearingBadge);
export default connect(mapStateToProps)(HearingBadge);
Loading