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) => ({ .map((row) => ({
day: row.age, day: row.age,
feedTotal: row.feed_total, feedTotal: row.feed_total,
iotWeight: weightByAge.get(row.age) ?? null, iotWeight: row.iot_weight > 0 ? row.iot_weight : (weightByAge.get(row.age) ?? null),
chickenLife: row.chicken_life, chickenLife: Math.max(row.chicken_life - row.harvest_total, 0),
harvestWeightKg: row.harvest_weight_total / 1000, harvestWeightKg: row.harvest_weight_total / 1000,
fcr: row.fcr > 0 ? row.fcr : null, fcr: row.fcr > 0 ? row.fcr : null,
})), })),
@@ -299,30 +299,36 @@ const FcrDashboardPage: React.FC<{ onSettings: () => void }> = ({ onSettings })
scalarScope={{ scalarScope={{
historyKey: 'tren_fcr_harian', historyKey: 'tren_fcr_harian',
derive: { derive: {
fcrTerakhir: { field: 'fcr_aktual', agg: 'lastValid', replaces: 'latestFcr' }, // Match FCR page StatCards: latest valid value, never a window mean.
totalPakan_karung: { fcrTerakhir_rasio: {
field: 'total_pakan_karung', 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', agg: 'last',
replaces: 'latestFeedTotal', replaces: 'pakan_karung_terakhir',
emptyAs: 0, emptyAs: 0,
}, },
bobotIot_gram: { bobotIotTerakhir_gram: {
field: 'bobot_iot_gram', field: 'bobot_iot_gram',
agg: 'lastValid', agg: 'lastValid',
replaces: 'latestIotWeight', replaces: 'bobot_iot_gram_terakhir',
}, },
ayamHidup_ekor: { ayamHidupTerakhir_ekor: {
field: 'ayam_hidup_ekor', field: 'ayam_hidup_ekor',
agg: 'last', agg: 'last',
replaces: 'latestChickenLife', replaces: 'ayam_hidup_ekor',
emptyAs: 0, emptyAs: 0,
}, },
}, },
drop: [ drop: [
'latestFcr', 'fcr_terakhir',
'latestFeedTotal', 'pakan_karung_terakhir',
'latestIotWeight', 'bobot_iot_gram_terakhir',
'latestChickenLife', 'ayam_hidup_ekor',
], ],
}} }}
/> />