Skip to content

Commit

Permalink
Merge branch 'feat/push-notification'
Browse files Browse the repository at this point in the history
  • Loading branch information
YehyeokBang committed Feb 1, 2024
2 parents fb31530 + a1efa28 commit aea5d8f
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions app/report/services/report_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,20 @@ func NewReportService(reportRepository repositories.ReportRepositoryInterface, u
}
}

var REQUEST_URL string
var client *http.Client

func init() {
REQUEST_URL = os.Getenv("AI_SERVER_API_URL")
client = &http.Client{}
}

func (service *ReportService) Analysis(c *gin.Context, input types.RequestAnalysis) (string, error) {
user, err := service.UserUtil.FindCurrentUser(c)
if err != nil {
return "Not Found User", err
}

REQUEST_URL := os.Getenv("AI_SERVER_API_URL")

u, _ := url.Parse(REQUEST_URL)

q := u.Query()
Expand All @@ -55,7 +61,16 @@ func (service *ReportService) Analysis(c *gin.Context, input types.RequestAnalys

message := "Video submitted successfully"

go Predict(*service, u.String(), *user, input)
errCh := make(chan error, 1)
go func() {
errCh <- Predict(*service, u.String(), *user, input)
}()

defer func() {
if err := <-errCh; err != nil {
fmt.Println(err, " [", user.ID, ", ", input.VideoURL, "]")
}
}()

return message, nil
}
Expand Down Expand Up @@ -100,8 +115,6 @@ func HandleRequest(url string) (types.ResponseAnalysis, error) {
return types.ResponseAnalysis{}, err
}

client := &http.Client{}

response, err := client.Do(req)
if err != nil {
return types.ResponseAnalysis{}, err
Expand Down

0 comments on commit aea5d8f

Please sign in to comment.