ai insight rework #2
This commit is contained in:
1 parent
9d76f54d33
commit
e1987d6999
39 files changed
+2311
-830
No files matched your search
@@ -145,14 +145,12 @@ const Dashboard: React.FC<Props> = ({ setView }) => {
|
||||
const latest = visibleKpis[0] ?? null;
|
||||
const anchorDate = latest?.date ?? null;
|
||||
|
||||
const kpisThroughAnchor = anchorDate
|
||||
? visibleKpis.filter((row) => row.date <= anchorDate)
|
||||
: [];
|
||||
const kpisThroughAnchor = anchorDate ? visibleKpis.filter((row) => row.date <= anchorDate) : [];
|
||||
const weightsThroughAnchor = anchorDate
|
||||
? throughVisibleDate(weights, visibleThrough).filter((row) => row.date <= anchorDate)
|
||||
: [];
|
||||
const weightOnAnchor = anchorDate
|
||||
? weightsThroughAnchor.find((row) => row.date === anchorDate) ?? weightsThroughAnchor[0]
|
||||
? (weightsThroughAnchor.find((row) => row.date === anchorDate) ?? weightsThroughAnchor[0])
|
||||
: null;
|
||||
|
||||
const startDate = selectedCycle?.start_date;
|
||||
@@ -291,28 +289,17 @@ const Dashboard: React.FC<Props> = ({ setView }) => {
|
||||
latest != null ? latest.feed : (karung?.feed_use_today ?? karung?.out_today ?? null),
|
||||
pakan_kumulatif_karung: karung?.feed_use_total ?? latest?.feed_total ?? null,
|
||||
ayam_hidup_ekor:
|
||||
latest != null
|
||||
? Math.max(0, latest.chicken_life - (latest.harvest_total ?? 0))
|
||||
: null,
|
||||
latest != null ? Math.max(0, latest.chicken_life - (latest.harvest_total ?? 0)) : null,
|
||||
persen_hidup: latest?.chicken_life_percentage ?? null,
|
||||
doc_in_ekor: selectedCycle?.doc_in_count ?? null,
|
||||
kematian_kumulatif_ekor: latest?.mortality_total ?? null,
|
||||
panen_kumulatif_ekor: latest?.harvest_total ?? null,
|
||||
// KPI harvest_weight_total is grams; insight context expects kg.
|
||||
tonase_panen_kg:
|
||||
latest?.harvest_weight_total != null
|
||||
? latest.harvest_weight_total / 1000
|
||||
: null,
|
||||
latest?.harvest_weight_total != null ? latest.harvest_weight_total / 1000 : null,
|
||||
uniformity_persen: weightOnAnchor?.uniformity ?? null,
|
||||
});
|
||||
}, [
|
||||
selectedKandangId,
|
||||
selectedKandang,
|
||||
selectedCycle,
|
||||
kpis,
|
||||
weights,
|
||||
karung,
|
||||
]);
|
||||
}, [selectedKandangId, selectedKandang, selectedCycle, kpis, weights, karung]);
|
||||
|
||||
const insightMetrics = useMemo(() => {
|
||||
if (selectedKandangId == null) return null;
|
||||
|
||||
Reference in new issue
Block a user