Skip to content

Commit

Permalink
Merge pull request #16621 from CDCgov/deployment/2024-11-21
Browse files Browse the repository at this point in the history
Deployment of 2024-11-21
  • Loading branch information
victor-chaparro authored Nov 21, 2024
2 parents 2fbf598 + 9258b5d commit 0c57bbb
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy_terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@ jobs:
terraform validate
terraform fmt -recursive
terraform plan -out ${{ needs.pre_job.outputs.env_name }}-tf.plan
# terraform apply -input=false -no-color -lock-timeout=600s -auto-approve ${{ needs.pre_job.outputs.env_name }}-tf.plan
terraform apply -input=false -no-color -lock-timeout=600s -auto-approve ${{ needs.pre_job.outputs.env_name }}-tf.plan
2 changes: 0 additions & 2 deletions frontend-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"date-fns": "^3.6.0",
"date-fns-tz": "^3.2.0",
"dompurify": "^3.1.7",
"downloadjs": "^1.4.7",
"export-to-csv-fix-source-map": "^0.2.1",
"focus-trap-react": "^10.3.0",
"history": "^5.3.0",
Expand Down Expand Up @@ -135,7 +134,6 @@
"@testing-library/user-event": "^14.5.2",
"@types/dompurify": "^3.0.5",
"@types/dotenv-flow": "^3.3.3",
"@types/downloadjs": "^1.4.6",
"@types/eslint__js": "^8.42.3",
"@types/github-slugger": "^1.3.0",
"@types/html-to-text": "^9.0.4",
Expand Down
45 changes: 13 additions & 32 deletions frontend-react/src/pages/deliveries/daily-data/ReportLink.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Button, Icon } from "@trussworks/react-uswds";
import download from "downloadjs";
import { PropsWithChildren } from "react";

import { downloadReport } from "./ReportsUtils";
import config from "../../../config";
import useSessionContext from "../../../contexts/Session/useSessionContext";
import { isDateExpired } from "../../../utils/DateTimeUtils";
Expand All @@ -28,13 +28,7 @@ const formatFileType = (fileType: string) => {
This element provides a download link on each row of the table and on the report
details page
*/
function ReportLink({
reportId,
fileType,
reportExpires,
children,
button,
}: PropsWithChildren<ReportLinkProps>) {
function ReportLink({ reportId, fileType, reportExpires, children, button }: PropsWithChildren<ReportLinkProps>) {
const { authState } = useSessionContext();
const { activeMembership } = useSessionContext();
const organization = activeMembership?.parsedName;
Expand All @@ -50,15 +44,7 @@ function ReportLink({
})
.then((res) => res.json())
.then((report) => {
// The filename to use for the download should not contain blob folders if present
let filename = decodeURIComponent(report.fileName);
const filenameStartIndex = filename.lastIndexOf("/");
if (
filenameStartIndex >= 0 &&
filename.length > filenameStartIndex + 1
)
filename = filename.substring(filenameStartIndex + 1);
download(report.content, filename, report.mimetype);
downloadReport(report);
});
}
};
Expand All @@ -73,21 +59,16 @@ function ReportLink({
} else {
return (
<>
{fileType !== undefined &&
!isDateExpired(reportExpires ?? "") && (
<Button
type="button"
outline
onClick={handleClick}
className="usa-button usa-button--outline float-right display-flex flex-align-center margin-left-1"
>
{formatFileType(fileType)}{" "}
<Icon.FileDownload
className="margin-left-1"
size={3}
/>
</Button>
)}
{fileType !== undefined && !isDateExpired(reportExpires ?? "") && (
<Button
type="button"
outline
onClick={handleClick}
className="usa-button usa-button--outline float-right display-flex flex-align-center margin-left-1"
>
{formatFileType(fileType)} <Icon.FileDownload className="margin-left-1" size={3} />
</Button>
)}
</>
);
}
Expand Down
26 changes: 21 additions & 5 deletions frontend-react/src/pages/deliveries/daily-data/ReportsUtils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import axios from "axios";
import download from "downloadjs";

import config from "../../../config";
import { RSReportInterface } from "../../../utils/ReportUtils";

const { RS_API_URL } = config;
export const reportDetailURL = (id: string, base?: string) =>
`${base ? base : RS_API_URL}/api/history/report/${id}`;
export const reportDetailURL = (id: string, base?: string) => `${base ? base : RS_API_URL}/api/history/report/${id}`;

export const getReportAndDownload = (
reportId: string,
Expand All @@ -31,9 +29,27 @@ export const getReportAndDownload = (
};

export const downloadReport = (report: RSReportInterface) => {
// Decode the file name from the report
let filename = decodeURIComponent(report.fileName);

// Extract the filename if it contains a path
const filenameStartIndex = filename.lastIndexOf("/");
if (filenameStartIndex >= 0 && filename.length > filenameStartIndex + 1)
if (filenameStartIndex >= 0 && filename.length > filenameStartIndex + 1) {
filename = filename.substring(filenameStartIndex + 1);
return download(report.content, filename, report.mimeType);
}

const blob = new Blob([report.content], { type: report.mimeType || "application/octet-stream" });

const url = URL.createObjectURL(blob);

// Create a temporary anchor element to trigger the download
const a = document.createElement("a");
a.href = url;
a.download = filename;

// Append the anchor to the DOM, trigger the download, and clean up
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
};
16 changes: 0 additions & 16 deletions frontend-react/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2654,13 +2654,6 @@ __metadata:
languageName: node
linkType: hard

"@types/downloadjs@npm:^1.4.6":
version: 1.4.6
resolution: "@types/downloadjs@npm:1.4.6"
checksum: 0e98425946c12315a7b9646edb75285bcc0fda2d59f9d296fa3bf9455ef62d6d73383c52ee86eec50e9b4cee6f9af9dba78c6fb56bc6444395b4ac4f76a86ec0
languageName: node
linkType: hard

"@types/escodegen@npm:^0.0.6":
version: 0.0.6
resolution: "@types/escodegen@npm:0.0.6"
Expand Down Expand Up @@ -5146,13 +5139,6 @@ __metadata:
languageName: node
linkType: hard

"downloadjs@npm:^1.4.7":
version: 1.4.7
resolution: "downloadjs@npm:1.4.7"
checksum: 4c546a28e7adcb1c290685f923add84e89582549f93502fa1b028194492522f716abb95a70f6ae464067a767e967806970d2a03e6262f8ccbcf3dd68e950d1da
languageName: node
linkType: hard

"eastasianwidth@npm:^0.2.0":
version: 0.2.0
resolution: "eastasianwidth@npm:0.2.0"
Expand Down Expand Up @@ -10365,7 +10351,6 @@ __metadata:
"@trussworks/react-uswds": ^9.1.0
"@types/dompurify": ^3.0.5
"@types/dotenv-flow": ^3.3.3
"@types/downloadjs": ^1.4.6
"@types/eslint__js": ^8.42.3
"@types/github-slugger": ^1.3.0
"@types/html-to-text": ^9.0.4
Expand All @@ -10392,7 +10377,6 @@ __metadata:
date-fns-tz: ^3.2.0
dompurify: ^3.1.7
dotenv-flow: ^4.1.0
downloadjs: ^1.4.7
eslint: 9.13.0
eslint-config-prettier: ^9.1.0
eslint-import-resolver-typescript: ^3.6.3
Expand Down
2 changes: 1 addition & 1 deletion prime-router/docs/getting-started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ A `ctrl-c` will escape the running ReportStream instance.
## Debugging

`./gradlew quickrun` or `./gradlew run` will open a debug port on your locally running ReportStream instance.
`./gradlew quickRun` or `./gradlew run` will open a debug port on your locally running ReportStream instance.
Connect your debugger remotely to port 5005.
For profiling use the JMX port 9090.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import gov.cdc.prime.router.report.ReportService
import org.apache.commons.lang3.StringUtils
import org.apache.logging.log4j.kotlin.Logging
import org.jooq.exception.DataAccessException
import java.util.Base64

class FHIRFunctions(
private val workflowEngine: WorkflowEngine = WorkflowEngine(),
Expand Down Expand Up @@ -204,7 +205,7 @@ class FHIRFunctions(
} catch (ex: SubmissionSenderNotFound) {
// This is a specific error case that can occur while handling a report via the new Submission service
// In a situation that the sender is not found there is not enough information to record a report event
// and we want a poison queue message to be immediately added so that the configuration can be fixed
// so, we want a poison queue message to be immediately added so that the configuration can be fixed
logger.error(ex)
val tableEntity = Submission(
ex.reportId.toString(),
Expand All @@ -213,14 +214,16 @@ class FHIRFunctions(
actionLogger.errors.takeIf { it.isNotEmpty() }?.map { it.detail.message }?.toString()
)
submissionTableService.insertSubmission(tableEntity)
queueAccess.sendMessage("${messageContent.messageQueueName}-poison", message)
val encodedMsg = Base64.getEncoder().encodeToString(message.toByteArray())
queueAccess.sendMessage("${messageContent.messageQueueName}-poison", encodedMsg)
return emptyList()
} catch (ex: Exception) {
// We're catching anything else that occurs because the most likely cause is a code or configuration error
// that will not be resolved if the message is automatically retried
// Instead, the error is recorded as an event and message is manually inserted into the poison queue
val report = databaseAccess.fetchReportFile(messageContent.reportId)
val poisonQueueMessageId = queueAccess.sendMessage("${messageContent.messageQueueName}-poison", message)
val encodedMsg = Base64.getEncoder().encodeToString(message.toByteArray())
val poisonQueueMessageId = queueAccess.sendMessage("${messageContent.messageQueueName}-poison", encodedMsg)
fhirEngine.reportEventService.sendReportProcessingError(
ReportStreamEventName.PIPELINE_EXCEPTION,
report,
Expand Down
5 changes: 3 additions & 2 deletions prime-router/src/test/kotlin/azure/FHIRFunctionsTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import org.jooq.tools.jdbc.MockResult
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import java.util.Base64
import java.util.UUID

class FHIRFunctionsTests {
Expand Down Expand Up @@ -98,7 +99,7 @@ class FHIRFunctionsTests {
verify(exactly = 1) {
QueueAccess.sendMessage(
"${QueueMessage.elrConvertQueueName}-poison",
queueMessage
Base64.getEncoder().encodeToString(queueMessage.toByteArray())
)
mockReportEventService.sendReportProcessingError(
ReportStreamEventName.PIPELINE_EXCEPTION,
Expand All @@ -124,7 +125,7 @@ class FHIRFunctionsTests {
verify(exactly = 0) {
QueueAccess.sendMessage(
"${QueueMessage.elrConvertQueueName}-poison",
queueMessage
Base64.getEncoder().encodeToString(queueMessage.toByteArray())
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ import tech.tablesaw.api.StringColumn
import tech.tablesaw.api.Table
import java.nio.charset.Charset
import java.time.OffsetDateTime
import java.util.Base64
import java.util.UUID

@Testcontainers
Expand Down Expand Up @@ -334,8 +335,7 @@ class FHIRConverterIntegrationTests {
verify(exactly = 1) {
QueueAccess.sendMessage(
"${QueueMessage.elrSubmissionConvertQueueName}-poison",
queueMessage

Base64.getEncoder().encodeToString(queueMessage.toByteArray())
)
}
}
Expand Down

0 comments on commit 0c57bbb

Please sign in to comment.