mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
Merge branch 'feat/umur' into 'development'
[FEAT][BE]: adjust calculate umur ayam at recording See merge request mbugroup/lti-api!500
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user