From 2f82cc9ce92b2a4fcbfd2f8c484b32aec69390f1 Mon Sep 17 00:00:00 2001 From: Brandon Sprague Date: Tue, 14 Jan 2025 19:04:11 -0800 Subject: [PATCH] Assorted QoL tweaks - Define some i18n strings - Only download the `audit_file.csv` for audits - Show/hide download/view buttons when it makes sense - Add some stragging env vars --- .../components/analysis/AccessButtons.vue | 37 ++++++++++++------- frontend/components/portfolio/ListView.vue | 7 ++++ frontend/lang/en.json | 1 + taskrunner/taskrunner.go | 9 +++++ 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/frontend/components/analysis/AccessButtons.vue b/frontend/components/analysis/AccessButtons.vue index 5edbd4c..8a25a50 100644 --- a/frontend/components/analysis/AccessButtons.vue +++ b/frontend/components/analysis/AccessButtons.vue @@ -42,25 +42,36 @@ const isViewable = computed(() => { const downloadInProgress = useState(`${statePrefix}.downloadInProgress`, () => false) const doDownload = async () => { downloadInProgress.value = true + // Just download the audit_file.csv for audits + const artifactsToDownload = props.analysis.analysisType === AnalysisType.ANALYSIS_TYPE_AUDIT ? props.analysis.artifacts.filter((a) => a.blob.fileName === 'audit_file.csv') : props.analysis.artifacts; const response: AccessBlobContentResp = await pactaClient.accessBlobContent({ - items: props.analysis.artifacts.map((asset): AccessBlobContentReqItem => ({ + items: artifactsToDownload.map((asset): AccessBlobContentReqItem => ({ blobId: asset.blob.id, })), }) - const zip = new JSZip() - await Promise.all(response.items.map( - async (item): Promise => { - const response = await fetch(item.downloadUrl) - const data = await response.blob() - const blob = presentOrFileBug(props.analysis.artifacts.find((artifact) => artifact.blob.id === item.blobId)).blob - const fileName = `${blob.fileName}` - zip.file(fileName, data) - }), - ) - const content = await zip.generateAsync({ type: 'blob' }) + + let content: Blob | null = null + let fileName: string | null = null + if (response.items.length === 1) { + const resp = await fetch(response.items[0].downloadUrl) + content = await resp.blob() + fileName = artifactsToDownload[0].blob.fileName + } else { + const zip = new JSZip() + await Promise.all(response.items.map( + async (item): Promise => { + const response = await fetch(item.downloadUrl) + const data = await response.blob() + const blob = presentOrFileBug(props.analysis.artifacts.find((artifact) => artifact.blob.id === item.blobId)).blob + const fileName = `${blob.fileName}` + zip.file(fileName, data) + }), + ) + content = await zip.generateAsync({ type: 'blob' }) + fileName = `${props.analysis.name}.zip` + } const element = document.createElement('a') element.href = URL.createObjectURL(content) - const fileName = `${props.analysis.name}.zip` element.download = fileName document.body.appendChild(element) element.click() diff --git a/frontend/components/portfolio/ListView.vue b/frontend/components/portfolio/ListView.vue index 41699b6..adb9d9d 100644 --- a/frontend/components/portfolio/ListView.vue +++ b/frontend/components/portfolio/ListView.vue @@ -377,6 +377,13 @@ const auditLogURL = (id: string) => { {{ slotProps.data.analyses.filter((a: Analysis) => a.analysisType === AnalysisType.ANALYSIS_TYPE_AUDIT).length }} {{ tt('Audits') }} + + {{ slotProps.data.analyses.filter((a: Analysis) => a.analysisType === AnalysisType.ANALYSIS_TYPE_DASHBOARD).length }} + {{ tt('Dashboards') }} + diff --git a/frontend/lang/en.json b/frontend/lang/en.json index 3775549..77f5e6b 100644 --- a/frontend/lang/en.json +++ b/frontend/lang/en.json @@ -208,6 +208,7 @@ "Details": "Details", "Groups": "Groups", "Reports": "Reports", + "Dashboards": "Dashboards", "Discard Changes": "Discard Changes", "InitiativesHelpText": "Initiatives allow you to contribute your data for bulk analysis as part of a regulatory or other project. Adding a portfolio to an initiative enables the initiative owner to run analysis over your data as part of bulk runs, and enables them to download your data.", "Audits": "Audits", diff --git a/taskrunner/taskrunner.go b/taskrunner/taskrunner.go index 1a50e83..8901e68 100644 --- a/taskrunner/taskrunner.go +++ b/taskrunner/taskrunner.go @@ -157,6 +157,15 @@ func (tr *TaskRunner) CreateAudit(ctx context.Context, req *task.CreateAuditRequ Key: "CREATE_AUDIT_REQUEST", Value: value, }, + // TODO(brandon): Unhardcode these + { + Key: "BENCHMARK_DIR", + Value: "/mnt/benchmark-data/65c1a416721b22a98c7925999ae03bc4", + }, + { + Key: "PACTA_DATA_DIR", + Value: "/mnt/pacta-data/2023Q4_20240718T150252Z", + }, }) }