|
1 | 1 | import { getProjectRisksReportQuery, getMembersByProjectIdQuery } from "../utils/reporting.utils";
|
2 |
| -import { ReportType } from "../models/reporting.model"; |
| 2 | +import { DefaultReportName, ReportType } from "../models/reporting.model"; |
3 | 3 |
|
4 | 4 | interface reportBodyData {
|
5 | 5 | projectTitle: string,
|
6 | 6 | projectOwner: string
|
7 | 7 | }
|
8 | 8 |
|
| 9 | +/** |
| 10 | + * Format the report name |
| 11 | + * if request body includes report name, return the report name as user requested |
| 12 | + * If not, return as {type}_{YYYYMMDD}_{HHMMSS} |
| 13 | +*/ |
| 14 | +export function getFormattedReportName(name: string, type: string) { |
| 15 | + let reportType; |
| 16 | + switch(type) { |
| 17 | + case ReportType.PROJECTRISK_REPORT: |
| 18 | + reportType = DefaultReportName.PROJECTRISK_REPORT; |
| 19 | + break; |
| 20 | + case ReportType.VENDOR_REPORT: |
| 21 | + reportType = DefaultReportName.VENDOR_REPORT; |
| 22 | + break; |
| 23 | + case ReportType.ASSESSMENT_REPORT: |
| 24 | + reportType = DefaultReportName.ASSESSMENT_REPORT; |
| 25 | + break; |
| 26 | + case ReportType.COMPLIANCE_REPORT: |
| 27 | + reportType = DefaultReportName.COMPLIANCE_REPORT; |
| 28 | + break; |
| 29 | + default: |
| 30 | + reportType = DefaultReportName.ALL_REPORT; |
| 31 | + } |
| 32 | + |
| 33 | + const date = new Date(); |
| 34 | + |
| 35 | + const year = date.getFullYear(); |
| 36 | + const month = String(date.getMonth() + 1).padStart(2, '0'); |
| 37 | + const day = String(date.getDate()).padStart(2, '0'); |
| 38 | + |
| 39 | + const hour = String(date.getHours()).padStart(2, '0'); |
| 40 | + const minute = String(date.getMinutes()).padStart(2, '0'); |
| 41 | + const second = String(date.getSeconds()).padStart(2, '0'); |
| 42 | + |
| 43 | + if(name.length === 0 ) { |
| 44 | + return `${type}_${year}${month}${day}_${hour}${minute}${second}`; |
| 45 | + } else { |
| 46 | + return `${name}`; |
| 47 | + } |
| 48 | +} |
| 49 | + |
9 | 50 | /*
|
10 | 51 | Get member lists by projectId
|
11 | 52 | Check whether the user belongs to current project
|
@@ -63,16 +104,16 @@ export async function getProjectRiskMarkdown (
|
63 | 104 | }
|
64 | 105 |
|
65 | 106 | const projectRiskMD = `
|
66 |
| -VerifyWise Project Risk Report |
| 107 | +VerifyWise project risk report |
67 | 108 | ========================
|
68 | 109 |
|
69 | 110 | This report is generated by the VeriftyWise Project Risk. It aims to provide a way to demonstrate their claims about the risks of their AI systems.
|
70 | 111 |
|
71 |
| -- **Report Date :** ${new Date().toLocaleDateString()} |
72 |
| -- **Project :** ${data.projectTitle} |
73 |
| -- **Owner :** ${data.projectOwner} |
| 112 | +- **Report Date ** ${new Date().toLocaleDateString()} |
| 113 | +- **Project ** ${data.projectTitle} |
| 114 | +- **Owner ** ${data.projectOwner} |
74 | 115 |
|
75 |
| -Project Risk Table |
| 116 | +Project risk table |
76 | 117 | -------------
|
77 | 118 | | Risk Name | Owner | Severity | Likelihood | Mitigation Status | Risk Level | Target Date |
|
78 | 119 | |----|----|----|----|----|----|----|
|
|
0 commit comments