Skip to content

Commit

Permalink
host_metrics date fix to make summary dates (datetime.datetime) compa…
Browse files Browse the repository at this point in the history
…rable to month: datetime.date (#15704)

* host_metrics date fix

* AAP-36839 Remove excess comments

* fix extra date() conversion

* actual fix

* datetime is a library, use datetime.datetime

---------

Co-authored-by: Andrea Restle-Lay <[email protected]>
  • Loading branch information
arrestle and Andrea Restle-Lay authored Dec 16, 2024
1 parent c1f0a83 commit 86d2024
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion awx/main/tasks/host_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,16 @@ def _find_or_create_summary(self, month):
self.records_to_update.append(summary)
return summary

def _find_summary(self, month):
def _find_summary(self, month: datetime.date):
"""
Existing summaries are ordered by month ASC.
This method is called with month in ascending order too => only 1 traversing is enough
"""
summary = None
while not summary and self.existing_summaries_idx < self.existing_summaries_cnt:
tmp = self.existing_summaries[self.existing_summaries_idx]
if isinstance(tmp, datetime.datetime):
tmp = tmp.date()
if tmp.date < month:
self.existing_summaries_idx += 1
elif tmp.date == month:
Expand Down

0 comments on commit 86d2024

Please sign in to comment.