Files
Backend/economic_overview/services.py
T

28 lines
712 B
Python
Raw Normal View History

2026-04-11 03:54:15 +03:30
from copy import deepcopy
2026-05-05 21:01:58 +03:30
from .defaults import EMPTY_ECONOMIC_OVERVIEW
2026-04-11 03:54:15 +03:30
from .models import EconomicOverviewLog
def get_economic_overview_data(farm=None):
2026-05-05 21:01:58 +03:30
data = deepcopy(EMPTY_ECONOMIC_OVERVIEW)
2026-04-11 03:54:15 +03:30
if farm is None:
return data
log = EconomicOverviewLog.objects.filter(farm=farm).first()
if log is None:
return data
2026-05-05 21:01:58 +03:30
data["status"] = "success"
data["source"] = "db"
data["warnings"] = []
2026-04-11 03:54:15 +03:30
if log.economic_data:
data["economicData"] = deepcopy(log.economic_data)
if log.chart_series:
data["chartSeries"] = deepcopy(log.chart_series)
if log.chart_categories:
data["chartCategories"] = deepcopy(log.chart_categories)
return data