Skip to content

Commit

Permalink
APPEALS-45202.Added button to trigger the job and return the appeals (#…
Browse files Browse the repository at this point in the history
…22375)

Co-authored-by: SHarshain <spoosa@razortalent.com>
  • Loading branch information
SHarshain and SHarshain authored Aug 1, 2024
1 parent 33d1aa4 commit 8928874
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 5 deletions.
5 changes: 5 additions & 0 deletions app/controllers/case_distribution_levers_tests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ def appeals_non_priority_ready_to_distribute
send_data csv_data, filename: filename
end

def run_return_legacy_appeals_to_board
ReturnLegacyAppealsToBoardJob.perform_now
head :ok
end

def appeals_distributed
# change this to the correct class
csv_data = AppealsDistributed.process
Expand Down
11 changes: 7 additions & 4 deletions app/jobs/return_legacy_appeals_to_board_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ class ReturnLegacyAppealsToBoardJob < CaseflowJob
def perform
begin
returned_appeal_job = create_returned_appeal_job
# Here add logic to process legacy appeals and return them to the board goes here
complete_returned_appeal_job(returned_appeal_job, "Job completed successfully")
# Logic to process legacy appeals and return to the board
appeals = LegacyDocket.new.appeals_tied_to_non_ssc_avljs
appeals = appeals.sort_by { |appeal| [appeal["priority"], appeal["bfd19"]] } unless appeals.empty?
complete_returned_appeal_job(returned_appeal_job, "Job completed successfully", appeals)
send_job_slack_report
rescue StandardError => error
errored_returned_appeal_job(returned_appeal_job, "Job failed with error: #{error.message}")
Expand All @@ -36,10 +38,11 @@ def create_returned_appeal_job
)
end

def complete_returned_appeal_job(returned_appeal_job, message)
def complete_returned_appeal_job(returned_appeal_job, message, appeals)
returned_appeal_job.update!(
completed_at: Time.zone.now,
stats: { message: message }.to_json
stats: { message: message }.to_json,
returned_appeals: appeals.map { |appeal| appeal["bfkey"] }
)
end

Expand Down
29 changes: 28 additions & 1 deletion client/app/caseDistribution/test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class CaseDistributionTest extends React.PureComponent {
isReseedingAod: false,
isReseedingNonAod: false,
isReseedingAmaDocketGoals: false,
isReseedingDocketPriority: false
isReseedingDocketPriority: false,
isReturnLegacyAppeals: false
};
}

Expand Down Expand Up @@ -79,6 +80,20 @@ class CaseDistributionTest extends React.PureComponent {
});
};

returnLegacyAppealsToBoard = () => {
this.setState({ isReturnLegacyAppeals: true });
ApiUtil.post('/case_distribution_levers_tests/run_return_legacy_appeals_to_board').then(() => {
this.setState({
isReturnLegacyAppeals: false,
});
}, (err) => {
console.warn(err);
this.setState({
isReturnLegacyAppeals: false,
});
});
};

render() {
const Router = this.props.router || BrowserRouter;
const appName = 'Case Distribution';
Expand Down Expand Up @@ -293,6 +308,18 @@ class CaseDistributionTest extends React.PureComponent {
</li>
</ul>
<hr />
<h2 id="case_movement">Case Movement</h2>
<ul>
<li>
<Button classNames={['usa-button-case-movement']}
onClick={this.returnLegacyAppealsToBoard}
name="Run ReturnLegacyAppealsToBoard job"
loading={this.state.isReturnLegacyAppeals}
loadingText="Processing ReturnLegacyAppealsToBoard job"
/>
</li>
</ul>
<hr />
<a href="#top"><button className="btn btn-primary">Back to Top</button></a>
</div>
);
Expand Down
9 changes: 9 additions & 0 deletions client/app/styles/caseDistribution/_test_seeds.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ $seed-table-border-color: #d6d7d9;
$seed-button-background-color: #0071bc;
$seed-button-font-color: #fff;
$seed-table-preview-bg-color: #f1f1f1;
$case-movement-button-bg-color: #07648d;

.test-seeds-num-field {
// width: auto;
Expand Down Expand Up @@ -122,3 +123,11 @@ $seed-table-preview-bg-color: #f1f1f1;
justify-content: flex-end;
flex-direction: row;
}

.usa-button-case-movement {
background: $case-movement-button-bg-color;
}

.usa-button-case-movement:hover {
background: $case-movement-button-bg-color;
}
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
post 'run_demo_non_aod_hearing_seeds'
post 'run-demo-ama-docket-goals'
post 'run-demo-docket-priority'
post 'run_return_legacy_appeals_to_board'
end
end

Expand Down

0 comments on commit 8928874

Please sign in to comment.