Merge branch 'development' into fix/daily-checklist

This commit is contained in:
ValdiANS
2026-05-04 16:29:07 +07:00
5 changed files with 47 additions and 19 deletions
@@ -119,9 +119,9 @@ func (r *DashboardRepositoryImpl) GetRecordingWeeklyMetrics(ctx context.Context,
var rows []RecordingWeeklyMetric
weekExpr := `CASE
WHEN r.day IS NULL OR r.day <= 0 THEN 1
WHEN UPPER(pf.category) = 'LAYING' THEN ((r.day - 1) / 7 + 1) + 17
ELSE ((r.day - 1) / 7 + 1)
WHEN r.day IS NULL OR r.day < 0 THEN 1
WHEN UPPER(pf.category) = 'LAYING' THEN (r.day / 7 + 1) + 17
ELSE (r.day / 7 + 1)
END`
db := r.DB().WithContext(ctx).
@@ -503,9 +503,9 @@ func (r *DashboardRepositoryImpl) GetComparisonWeeklyMetrics(ctx context.Context
var rows []ComparisonWeeklyMetric
weekExpr := `CASE
WHEN r.day IS NULL OR r.day <= 0 THEN 1
WHEN UPPER(pf.category) = 'LAYING' THEN ((r.day - 1) / 7 + 1) + 17
ELSE ((r.day - 1) / 7 + 1)
WHEN r.day IS NULL OR r.day < 0 THEN 1
WHEN UPPER(pf.category) = 'LAYING' THEN (r.day / 7 + 1) + 17
ELSE (r.day / 7 + 1)
END`
db := r.DB().WithContext(ctx).
@@ -574,9 +574,9 @@ func (r *DashboardRepositoryImpl) GetEggQualityWeeklyMetrics(ctx context.Context
var rows []EggQualityWeeklyMetric
weekExpr := `CASE
WHEN r.day IS NULL OR r.day <= 0 THEN 1
WHEN UPPER(pf.category) = 'LAYING' THEN ((r.day - 1) / 7 + 1) + 17
ELSE ((r.day - 1) / 7 + 1)
WHEN r.day IS NULL OR r.day < 0 THEN 1
WHEN UPPER(pf.category) = 'LAYING' THEN (r.day / 7 + 1) + 17
ELSE (r.day / 7 + 1)
END`
db := r.DB().WithContext(ctx).
@@ -616,9 +616,9 @@ func (r *DashboardRepositoryImpl) GetEggWeightWeeklyGrams(ctx context.Context, s
var rows []WeeklyEggWeightMetric
weekExpr := `CASE
WHEN r.day IS NULL OR r.day <= 0 THEN 1
WHEN UPPER(pf.category) = 'LAYING' THEN ((r.day - 1) / 7 + 1) + 17
ELSE ((r.day - 1) / 7 + 1)
WHEN r.day IS NULL OR r.day < 0 THEN 1
WHEN UPPER(pf.category) = 'LAYING' THEN (r.day / 7 + 1) + 17
ELSE (r.day / 7 + 1)
END`
db := r.DB().WithContext(ctx).
@@ -647,9 +647,9 @@ func (r *DashboardRepositoryImpl) GetFeedUsageWeeklyByUom(ctx context.Context, s
var rows []WeeklyFeedUsageMetric
weekExpr := `CASE
WHEN r.day IS NULL OR r.day <= 0 THEN 1
WHEN UPPER(pf.category) = 'LAYING' THEN ((r.day - 1) / 7 + 1) + 17
ELSE ((r.day - 1) / 7 + 1)
WHEN r.day IS NULL OR r.day < 0 THEN 1
WHEN UPPER(pf.category) = 'LAYING' THEN (r.day / 7 + 1) + 17
ELSE (r.day / 7 + 1)
END`
db := r.DB().WithContext(ctx).
@@ -2460,7 +2460,7 @@ func (s *recordingService) computeRecordingDay(ctx context.Context, projectFlock
return 0, fiber.NewError(fiber.StatusBadRequest, "Record date tidak boleh sebelum tanggal chick in")
}
return diff + 1, nil
return diff, nil
}
func (s *recordingService) computeAndUpdateMetrics(ctx context.Context, tx *gorm.DB, recording *entity.Recording) error {
@@ -2621,8 +2621,8 @@ func (s *recordingService) computeAndUpdateMetrics(ctx context.Context, tx *gorm
if isGrowing {
week := 0
if recording.Day != nil && *recording.Day > 0 {
week = (*recording.Day-1)/7 + 1
if recording.Day != nil && *recording.Day >= 0 {
week = *recording.Day/7 + 1
}
if week > 0 && s.Repository != nil {
meanBw, ok, err := s.Repository.GetUniformityMeanBwByWeek(tx, recording.ProjectFlockKandangId, week)