Skip to content

Commit

Permalink
Merge pull request #20 from MZC-CSC/develop
Browse files Browse the repository at this point in the history
bug fix for estimate forecast cost group by then count query
  • Loading branch information
MZC-CSC authored Nov 5, 2024
2 parents b8131c7 + 1e4b995 commit 89495ea
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions internal/core/cost/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ func (r *CostRepository) GetEstimateForecastCostInfosTx(ctx context.Context, par
Group("provider, resource_type, category, actual_resource_id, unit, date")
}


if err := d.Table("(?) AS sub", query).Count(&totalRows).Error; err != nil {
return err
}

if param.DateOrder != "" {
query = query.Order("date " + string(param.DateOrder))
}
Expand All @@ -270,10 +275,6 @@ func (r *CostRepository) GetEstimateForecastCostInfosTx(ctx context.Context, par
query = query.Order("resource_type " + string(param.ResourceTypeOrder))
}

if err := query.Count(&totalRows).Error; err != nil {
return err
}

offset := (param.Page - 1) * param.Size
query = query.Offset(offset).
Limit(param.Size)
Expand Down

0 comments on commit 89495ea

Please sign in to comment.