108 lines
3.3 KiB
TypeScript
108 lines
3.3 KiB
TypeScript
import { PopulationDataPoint, LiveCount } from '../types';
|
|
|
|
export const getInitialPopulationHistory = (totalPopulation: number): PopulationDataPoint[] => {
|
|
const history: PopulationDataPoint[] = Array.from({ length: 7 }, (_, i) => {
|
|
const date = new Date();
|
|
date.setDate(date.getDate() - (6 - i));
|
|
const basePopulation = totalPopulation - totalPopulation * 0.01;
|
|
return {
|
|
date: date.toLocaleDateString('id-ID', { day: '2-digit', month: 'short' }),
|
|
population: Math.floor(
|
|
basePopulation -
|
|
(6 - i) * (totalPopulation * 0.001) +
|
|
Math.random() * (totalPopulation * 0.002) -
|
|
totalPopulation * 0.001
|
|
),
|
|
};
|
|
});
|
|
// Set the last point to the current total population
|
|
const lastPoint = history[history.length - 1];
|
|
if (lastPoint) {
|
|
lastPoint.population = totalPopulation;
|
|
}
|
|
return history;
|
|
};
|
|
|
|
export const initialLiveCounts: LiveCount[] = [
|
|
{
|
|
cameraId: 'cam2',
|
|
cameraName: 'Kamera Sudut Kiri Zona A',
|
|
locationName: 'Peternakan Pusat, Jawa Barat / Kandang A (Broiler) / Lantai 1',
|
|
count: 6210,
|
|
status: 'online',
|
|
imageUrl: 'https://i.imgur.com/8p8Yq3g.jpg',
|
|
},
|
|
{
|
|
cameraId: 'cam3',
|
|
cameraName: 'Kamera Sudut Kanan Zona C',
|
|
locationName: 'Peternakan Pusat, Jawa Barat / Kandang B (Broiler) / Lantai 1',
|
|
count: 6150,
|
|
status: 'online',
|
|
imageUrl: 'https://i.imgur.com/gK9p29k.jpg',
|
|
},
|
|
{
|
|
cameraId: 'cam5',
|
|
cameraName: 'Kamera Kandang C - Lt 1',
|
|
locationName: 'Peternakan Pusat, Jawa Barat / Kandang C (Broiler) / Lantai 1',
|
|
count: 6380,
|
|
status: 'online',
|
|
imageUrl: 'https://i.imgur.com/Lz6S3fA.jpg',
|
|
},
|
|
{
|
|
cameraId: 'cam6',
|
|
cameraName: 'Kamera Kandang C - Lt 2',
|
|
locationName: 'Peternakan Pusat, Jawa Barat / Kandang C (Broiler) / Lantai 2',
|
|
count: 6136,
|
|
status: 'online',
|
|
imageUrl: 'https://i.imgur.com/rLd7gP9.jpg',
|
|
},
|
|
{
|
|
cameraId: 'cam7',
|
|
cameraName: 'Kamera K-01 (Kalimantan)',
|
|
locationName: 'Peternakan Satelit, Kalimantan / Kandang K-01 / Lantai 1',
|
|
count: 0,
|
|
status: 'processing',
|
|
imageUrl: 'https://i.imgur.com/wUSv0bM.png',
|
|
},
|
|
{
|
|
cameraId: 'cam4',
|
|
cameraName: 'Kamera Feeder Zona D',
|
|
locationName: 'Peternakan Pusat, Jawa Barat / Kandang A (Broiler) / Lantai 2',
|
|
count: 0,
|
|
status: 'offline',
|
|
imageUrl: 'https://i.imgur.com/3Q3sfn4.png',
|
|
},
|
|
{
|
|
cameraId: 'cam10',
|
|
cameraName: 'Kamera Tengah A-2',
|
|
locationName: 'Peternakan Pusat, Jawa Barat / Kandang A (Broiler) / Lantai 2',
|
|
count: 6185,
|
|
status: 'online',
|
|
imageUrl: 'https://i.imgur.com/gK9p29k.jpg',
|
|
},
|
|
{
|
|
cameraId: 'cam11',
|
|
cameraName: 'Kamera Feeder B-1',
|
|
locationName: 'Peternakan Pusat, Jawa Barat / Kandang B (Broiler) / Lantai 1',
|
|
count: 6090,
|
|
status: 'online',
|
|
imageUrl: 'https://i.imgur.com/8p8Yq3g.jpg',
|
|
},
|
|
{
|
|
cameraId: 'cam12',
|
|
cameraName: 'Kamera Percobaan #1',
|
|
locationName: 'Peternakan Cabang, Sumatra / Kandang Percobaan / Lantai Dasar',
|
|
count: 480,
|
|
status: 'online',
|
|
imageUrl: 'https://i.imgur.com/Lz6S3fA.jpg',
|
|
},
|
|
{
|
|
cameraId: 'cam8',
|
|
cameraName: 'Kamera K-02 (Kalimantan)',
|
|
locationName: 'Peternakan Satelit, Kalimantan / Kandang K-02 / Lantai 1',
|
|
count: 0,
|
|
status: 'offline',
|
|
imageUrl: 'https://i.imgur.com/3Q3sfn4.png',
|
|
},
|
|
];
|