Skip to content
This repository has been archived by the owner on Jan 20, 2021. It is now read-only.

Commit

Permalink
fix period_from being greater thanperiod_to on 1st of month
Browse files Browse the repository at this point in the history
  • Loading branch information
badguy99 committed May 1, 2020
1 parent 9c061ed commit 33e9417
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions apps/octocost/octocost.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ def cost_and_usage_callback(self, kwargs):
startyear = datetime.date(today.year, 1, 1)
startmonth = datetime.date(today.year, today.month, 1)

if today == startmonth:
if today.month == 1:
startmonth = datetime.date(today.year-1, 12, 1)
else:
startmonth = datetime.date(today.year, today.month-1, 1)
if today == startyear:
startyear = datetime.date(today.year-1, 1, 1)

if self.startdate > startmonth:
startmonth = self.startdate

Expand Down Expand Up @@ -136,6 +144,10 @@ def calculate_count(self, start):

def calculate_cost_and_usage(self, start):
self.calculate_count(start=start)
self.log('period_from: {}T00:00:00Z'.format(start.isoformat()),
level='DEBUG')
self.log('period_to: {}T23:59:59Z'.format(self.yesterday.isoformat()),
level='DEBUG')
rconsumption = requests.get(url=self.useurl +
'?order_by=period&period_from=' +
start.isoformat() +
Expand Down

0 comments on commit 33e9417

Please sign in to comment.