Skip to content

Commit

Permalink
Add time_agg param to Indicator class
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmunoznovoa committed Jan 22, 2025
1 parent 2a70908 commit ec8baa0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion esios/indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class Indicator(base.RESTResource):
path = 'indicators'
time_agg = 'sum'

@base.apimethod
def get(self, start_date, end_date):
Expand All @@ -16,10 +17,11 @@ def get(self, start_date, end_date):
if end_date.tzinfo is None:
raise Exception('End date must have time zone')
time_trunc = 'hour'
time_agg = self.time_agg
start_date = start_date.isoformat()
end_date = end_date.isoformat()
params = base.get_params(
('start_date', 'end_date', 'time_trunc'), locals()
('start_date', 'end_date', 'time_trunc', 'time_agg'), locals()
)
request = http.Request('GET', self.get_url(), params)
return request, parsers.parse_json
Expand All @@ -30,6 +32,7 @@ class ProfilePVPC(Indicator):

class DemandaDiariaElectricaPeninsularPrevista(Indicator):
path = 'indicators/460'
time_agg = 'average'

class ProfilePVPC20A(ProfilePVPC):
path = 'indicators/526'
Expand Down Expand Up @@ -228,6 +231,7 @@ class mhpPowerFactorControl(Indicator):

class DemandaDiariaElectricaPeninsularReal(Indicator):
path = 'indicators/1293'
time_agg = 'average'

class mhpEnergyBalanceFree(Indicator):
path = 'indicators/1366'
Expand Down

0 comments on commit ec8baa0

Please sign in to comment.