adjust fcr page to match dashboard-cpsp

This commit is contained in:
Alberto-Audrix committed 2026-10-05 15:24:30 +07:00
1 parent 04678ef773
commit 7e8c06d36f
1 file changed
+20 -14
+20 -14
View File
@@ -218,8 +218,8 @@ const FcrDashboardPage: React.FC<{ onSettings: () => void }> = ({ onSettings })
.map((row) => ({
day: row.age,
feedTotal: row.feed_total,
iotWeight: weightByAge.get(row.age) ?? null,
chickenLife: row.chicken_life,
iotWeight: row.iot_weight > 0 ? row.iot_weight : (weightByAge.get(row.age) ?? null),
chickenLife: Math.max(row.chicken_life - row.harvest_total, 0),
harvestWeightKg: row.harvest_weight_total / 1000,
fcr: row.fcr > 0 ? row.fcr : null,
})),
@@ -299,30 +299,36 @@ const FcrDashboardPage: React.FC<{ onSettings: () => void }> = ({ onSettings })
scalarScope={{
historyKey: 'tren_fcr_harian',
derive: {
fcrTerakhir: { field: 'fcr_aktual', agg: 'lastValid', replaces: 'latestFcr' },
totalPakan_karung: {
field: 'total_pakan_karung',
// Match FCR page StatCards: latest valid value, never a window mean.
fcrTerakhir_rasio: {
field: 'fcr_aktual',
agg: 'lastValid',
replaces: 'fcr_terakhir',
},
// Cumulative metrics: 0 is valid (not started yet), use 'last' with emptyAs: 0
pakanTerakhir_karung: {
field: 'pakan_karung',
agg: 'last',
replaces: 'latestFeedTotal',
replaces: 'pakan_karung_terakhir',
emptyAs: 0,
},
bobotIot_gram: {
bobotIotTerakhir_gram: {
field: 'bobot_iot_gram',
agg: 'lastValid',
replaces: 'latestIotWeight',
replaces: 'bobot_iot_gram_terakhir',
},
ayamHidup_ekor: {
ayamHidupTerakhir_ekor: {
field: 'ayam_hidup_ekor',
agg: 'last',
replaces: 'latestChickenLife',
replaces: 'ayam_hidup_ekor',
emptyAs: 0,
},
},
drop: [
'latestFcr',
'latestFeedTotal',
'latestIotWeight',
'latestChickenLife',
'fcr_terakhir',
'pakan_karung_terakhir',
'bobot_iot_gram_terakhir',
'ayam_hidup_ekor',
],
}}
/>