Skip to content

Commit

Permalink
Return empty list when latest analysis does not exist.
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Ortel <[email protected]>
  • Loading branch information
jortel committed Feb 13, 2024
1 parent e1fa5f6 commit 100761e
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions api/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -917,13 +917,25 @@ func (h AnalysisHandler) AppIssueReports(ctx *gin.Context) {
model.Issue
Files int
}
// Latest
id := h.pk(ctx)
err := h.DB(ctx).First(&model.Application{}, id).Error
if err != nil {
_ = ctx.Error(err)
return
}
// Latest
analysis := &model.Analysis{}
db := h.DB(ctx).Where("ApplicationID", id)
result := db.Last(analysis)
if result.Error != nil {
_ = ctx.Error(result.Error)
err = db.Last(analysis).Error
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
h.Respond(
ctx,
http.StatusOK,
resources)
} else {
_ = ctx.Error(err)
}
return
}
// Filter
Expand Down

0 comments on commit 100761e

Please sign in to comment.