Skip to content

Commit

Permalink
Set exception code to be integer
Browse files Browse the repository at this point in the history
  • Loading branch information
richardhallett committed Feb 7, 2024
1 parent c7b09a9 commit 707af8b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
2 changes: 1 addition & 1 deletion internal/app/reports/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type ReportingPeriod struct {
}

type Exception struct {
Code string `json:"code"`
Code int `json:"code"`
Severity string `json:"severity"`
Message string `json:"message"`
HelpUrl string `json:"help-url"`
Expand Down
17 changes: 5 additions & 12 deletions internal/app/reports/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (service *ReportsService) GenerateDatasetUsageReport(repoId string, startDa
// This information would need to come from our API which would require a lookup based on dataset-id
// This could provide too much of an overhead for report generation.
exceptions = append(exceptions, Exception{
Code: "3071",
Code: 3071,
Severity: "warning",
Message: "dataset-title",
Data: "dataset-title is unavailable in this report, can be obtained from metadata lookup based on dataset-id",
Expand All @@ -92,22 +92,22 @@ func (service *ReportsService) GenerateDatasetUsageReport(repoId string, startDa
// Add missing attribute exceptions for potentially missing data
if sharedData.Platform == "" {
exceptions = append(exceptions, Exception{
Code: "3071",
Code: 3071,
Severity: "warning",
Message: "platform",
})
}
if sharedData.Publisher == "" {
exceptions = append(exceptions, Exception{
Code: "3071",
Code: 3071,
Severity: "warning",
Message: "publisher",
Data: "publisher is unavailable in this report, can be obtained from metadata lookup based on dataset-id",
})
}
if sharedData.PublisherId == "" {
exceptions = append(exceptions, Exception{
Code: "3071",
Code: 3071,
Severity: "warning",
Message: "publisher-id",
Data: "publisher-id is unavailable in this report, can be obtained from metadata lookup based on dataset-id",
Expand All @@ -117,7 +117,7 @@ func (service *ReportsService) GenerateDatasetUsageReport(repoId string, startDa
if addCompressedHeader {
// Add exception that this will be compressed report
exceptions = append(exceptions, Exception{
Code: "69",
Code: 69,
Message: "Report is compressed using gzip",
Severity: "warning",
HelpUrl: "https://github.com/datacite/sashimi",
Expand Down Expand Up @@ -251,13 +251,6 @@ func SendReportToAPI(reportsAPIEndpoint string, compressedJson []byte, jwt strin
return err
}

// Print response body
buf := new(bytes.Buffer)
buf.ReadFrom(res.Body)
newStr := buf.String()
log.Println(newStr)


// Check response code
switch res.StatusCode {
case http.StatusCreated:
Expand Down

0 comments on commit 707af8b

Please sign in to comment.