UPDATE
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
from copy import deepcopy
|
||||
|
||||
from .mock_data import ECONOMIC_OVERVIEW
|
||||
from .models import EconomicOverviewLog
|
||||
|
||||
|
||||
def get_economic_overview_data(farm=None):
|
||||
data = deepcopy(ECONOMIC_OVERVIEW)
|
||||
|
||||
if farm is None:
|
||||
return data
|
||||
|
||||
log = EconomicOverviewLog.objects.filter(farm=farm).first()
|
||||
if log is None:
|
||||
return data
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user