4 Commits

Author SHA1 Message Date
calli
370400ce99 extract launchpad ids to const and recolor storage fill rates 2025-04-28 18:32:26 +03:00
calli
93507ea98e add pino logger configuration correctly 2025-04-28 18:27:35 +03:00
calli
7915d2bd29 update docker compose file 2025-04-28 18:27:18 +03:00
calli
294720f776 use planets last_update to calculate the imports depletion 2025-04-28 18:10:32 +03:00
4 changed files with 20 additions and 23 deletions

View File

@@ -1,5 +1,3 @@
---
version: "2.1"
services:
eve-pi:
image: ghcr.io/calli-eve/eve-pi:latest

View File

@@ -1,5 +1,5 @@
import { ColorContext, SessionContext } from "@/app/context/Context";
import { PI_TYPES_MAP, STORAGE_IDS, STORAGE_CAPACITIES, PI_PRODUCT_VOLUMES, EVE_IMAGE_URL, PI_SCHEMATICS } from "@/const";
import { PI_TYPES_MAP, STORAGE_IDS, STORAGE_CAPACITIES, PI_PRODUCT_VOLUMES, EVE_IMAGE_URL, PI_SCHEMATICS, LAUNCHPAD_IDS } from "@/const";
import { planetCalculations } from "@/planets";
import { AccessToken, PlanetWithInfo } from "@/types";
import CloseIcon from "@mui/icons-material/Close";
@@ -351,8 +351,12 @@ export const PlanetTableRow = ({
const cycleTime = schematic?.cycle_time ?? 3600;
const consumptionPerHour = i.quantity * i.factoryCount * (3600 / cycleTime);
// Calculate time until depletion in hours
const hoursUntilDepletion = consumptionPerHour > 0 ? totalAmount / consumptionPerHour : 0;
// Calculate time until depletion in hours, starting from last_update
const lastUpdate = DateTime.fromISO(planet.last_update);
const now = DateTime.now();
const hoursSinceUpdate = now.diff(lastUpdate, 'hours').hours;
const remainingAmount = Math.max(0, totalAmount - (consumptionPerHour * hoursSinceUpdate));
const hoursUntilDepletion = consumptionPerHour > 0 ? remainingAmount / consumptionPerHour : 0;
return (
<div
@@ -363,7 +367,9 @@ export const PlanetTableRow = ({
{totalAmount > 0 && (
<Tooltip title={
<>
<div>Total: {totalAmount.toFixed(1)} units</div>
<div>Total in storage: {totalAmount.toFixed(1)} units</div>
<div>Consumption rate: {consumptionPerHour.toFixed(1)} units/hour</div>
<div>Last update: {lastUpdate.toFormat('yyyy-MM-dd HH:mm:ss')}</div>
<div>Will be depleted in {hoursUntilDepletion.toFixed(1)} hours</div>
</>
}>
@@ -460,25 +466,18 @@ export const PlanetTableRow = ({
{storageFacilities.length === 0 &&<Typography fontSize={theme.custom.smallText}>No storage</Typography>}
{storageFacilities
.sort((a, b) => {
const isALaunchpad = a.type_id === 2256 || a.type_id === 2542 || a.type_id === 2543 || a.type_id === 2544 || a.type_id === 2552 || a.type_id === 2555 || a.type_id === 2556 || a.type_id === 2557;
const isBLaunchpad = b.type_id === 2256 || b.type_id === 2542 || b.type_id === 2543 || b.type_id === 2544 || b.type_id === 2552 || b.type_id === 2555 || b.type_id === 2556 || b.type_id === 2557;
const isALaunchpad = LAUNCHPAD_IDS.includes(a.type_id);
const isBLaunchpad = LAUNCHPAD_IDS.includes(b.type_id);
return isALaunchpad === isBLaunchpad ? 0 : isALaunchpad ? -1 : 1;
})
.map((storage) => {
const storageInfo = getStorageInfo(storage);
if (!storageInfo) return null;
const isLaunchpad = storage.type_id === 2256 ||
storage.type_id === 2542 ||
storage.type_id === 2543 ||
storage.type_id === 2544 ||
storage.type_id === 2552 ||
storage.type_id === 2555 ||
storage.type_id === 2556 ||
storage.type_id === 2557;
const isLaunchpad = LAUNCHPAD_IDS.includes(storage.type_id);
const fillRate = storageInfo.fillRate;
const color = fillRate > 95 ? '#ff0000' : fillRate > 80 ? '#ffd700' : 'inherit';
const color = fillRate > 90 ? '#ff0000' : fillRate > 80 ? '#ffa500' : fillRate > 60 ? '#ffd700' : 'inherit';
return (
<div key={`storage-${character.character.characterId}-${planet.planet_id}-${storage.pin_id}`} style={{ display: "flex", alignItems: "center" }}>

View File

@@ -1080,3 +1080,5 @@ export const STORAGE_CAPACITIES: Record<number, number> = {
2556: 10000, // Plasma Launchpad
2557: 10000, // Storm Launchpad
};
export const LAUNCHPAD_IDS = [2256, 2542, 2543, 2544, 2552, 2555, 2556, 2557];

View File

@@ -2,14 +2,12 @@ import pino from 'pino';
const logger = pino({
level: process.env.LOG_LEVEL || 'info',
transport: {
target: 'pino-pretty',
options: {
colorize: true,
translateTime: 'SYS:standard',
ignore: 'pid,hostname',
formatters: {
level: (label) => {
return { level: label };
},
},
timestamp: () => `,"time":"${new Date().toISOString()}"`,
base: {
env: process.env.NODE_ENV,
},