Skip to content

Commit

Permalink
Merge pull request #82 from openinfradev/fix_pod_calendar
Browse files Browse the repository at this point in the history
tirivial. fix pod calendar on dashboard.
  • Loading branch information
ktkfree authored Jun 19, 2023
2 parents 176094a + 44121c8 commit 76c8379
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/repository/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (r *AlertRepository) Fetch(organizationId string) (out []domain.Alert, err
func (r *AlertRepository) FetchPodRestart(organizationId string, start time.Time, end time.Time) (out []domain.Alert, err error) {
var alerts []Alert
res := r.db.Preload(clause.Associations).Order("created_at DESC").
Where("organization_id = ? AND created_at BETWEEN ? AND ?", organizationId, start, end).
Where("organization_id = ? AND name = 'pod-restart-frequently' AND created_at BETWEEN ? AND ?", organizationId, start, end).
Find(&alerts)
if res.Error != nil {
return nil, res.Error
Expand Down
5 changes: 5 additions & 0 deletions internal/usecase/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ func (u *DashboardUsecase) getChartFromPrometheus(organizationId string, chartTy
}
}
{
series : [
{
Expand Down Expand Up @@ -390,6 +391,10 @@ func (u *DashboardUsecase) getChartFromPrometheus(organizationId string, chartTy
}
baseDate := d.Format("2006-01-02")

if baseDate > now.Format("2006-01-02") {
break
}

cntPodRestart := 0
for _, alert := range alerts {
strDate := alert.CreatedAt.Format("2006-01-02")
Expand Down

0 comments on commit 76c8379

Please sign in to comment.