From 46888fab9b5d89b5a8e6a2fc6c5fd30062fa96b2 Mon Sep 17 00:00:00 2001 From: Grady Ward Date: Tue, 2 Jan 2024 13:29:29 -0700 Subject: [PATCH] WIP --- azure/azevents/azevents.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/azure/azevents/azevents.go b/azure/azevents/azevents.go index 87f99ee..e1413f2 100644 --- a/azure/azevents/azevents.go +++ b/azure/azevents/azevents.go @@ -44,6 +44,8 @@ type DB interface { IncompleteUploads(tx db.Tx, ids []pacta.IncompleteUploadID) (map[pacta.IncompleteUploadID]*pacta.IncompleteUpload, error) UpdateIncompleteUpload(tx db.Tx, id pacta.IncompleteUploadID, mutations ...db.UpdateIncompleteUploadFn) error + + CreateAnalysisArtifact(tx db.Tx, a *pacta.AnalysisArtifact) (pacta.AnalysisArtifactID, error) } const parsedPortfolioPath = "/events/parsed_portfolio" @@ -209,7 +211,11 @@ func (s *Server) verifyWebhook(next http.Handler) http.Handler { func (s *Server) RegisterHandlers(r chi.Router) { r.Use(s.verifyWebhook) - r.Post(parsedPortfolioPath, func(w http.ResponseWriter, r *http.Request) { + r.Post(parsedPortfolioPath, s.handleParsePortfolioResponse()) +} + +func (s *Server) handleParsePortfolioResponse() http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { var reqs []struct { Data *task.ParsePortfolioResponse `json:"data"` EventType string `json:"eventType"` @@ -317,7 +323,7 @@ func (s *Server) RegisterHandlers(r chi.Router) { zap.Int("incomplete_upload_count", len(req.Data.Request.IncompleteUploadIDs)), zap.Strings("portfolio_ids", asStrs(portfolioIDs)), zap.Int("portfolio_count", len(portfolioIDs))) - }) + } } func asStrs[T ~string](ts []T) []string {