Skip to content

Commit

Permalink
Send compressed json via worker
Browse files Browse the repository at this point in the history
  • Loading branch information
richardhallett committed Feb 5, 2024
1 parent 51c1974 commit 3f55408
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
18 changes: 9 additions & 9 deletions cmd/worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,20 @@ func report_job(repoId string, beginDate time.Time, endDate time.Time, platform
}

// Write report to file
filename := "report_" + repoId + "_" + beginDate.Format("2006-01-02") + "_" + endDate.Format("2006-01-02") + "_" + platform + "_" + publisher + "_" + publisherId + "_" + string(index) + ".json"
file, err := os.Create(filename)
if err != nil {
return err
}
defer file.Close()
// filename := "report_" + repoId + "_" + beginDate.Format("2006-01-02") + "_" + endDate.Format("2006-01-02") + "_" + platform + "_" + publisher + "_" + publisherId + "_" + string(index) + ".json"
// file, err := os.Create(filename)
// if err != nil {
// return err
// }
// defer file.Close()

file.Write(reportJson)
//file.Write(reportJson)

// Gzip json
//compressedJson, _ := gzipData(reportJson)
compressedJson, _ := gzipData(reportJson)

// Send to Reports API
err = reports.SendReportToAPI(reportsAPIEndpoint, reportJson, config.DataCite.JWT)
err = reports.SendReportToAPI(reportsAPIEndpoint, compressedJson, config.DataCite.JWT)

if err != nil {
return err
Expand Down
3 changes: 1 addition & 2 deletions internal/app/reports/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,7 @@ func SendReportToAPI(reportsAPIEndpoint string, compressedJson []byte, jwt strin
}

// Set content type to be gzip as report will be compressed
//req.Header.Set("Content-Type", "application/gzip")
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Content-Type", "application/gzip")

// Add JWT token to request
req.Header.Set("Authorization", "Bearer " + jwt)
Expand Down

0 comments on commit 3f55408

Please sign in to comment.