Skip to content

Commit

Permalink
Merge pull request #81 from deNBI/refactor/weight-timestamps
Browse files Browse the repository at this point in the history
feat(weights): reversed timestamps
  • Loading branch information
eKatchko authored Jun 10, 2021
2 parents 60068c2 + c7e3cd2 commit 5164c91
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions project_usage_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ def get_instance_weight(self, metric_tag, metric_amount, started_date):
instance_started_timestamp = datetime.strptime(started_date, "%Y-%m-%dT%H:%M:%S.%f").timestamp()
if self.weights is not None and len(self.weights) != 0:
sorted_timestamps = sorted(self.weights.keys())
max_timestamp = max(sorted_timestamps)
min_timestamp = min(sorted_timestamps)
associated_weights = None
for timestamp in sorted_timestamps:
if instance_started_timestamp <= timestamp or max_timestamp == timestamp:
for timestamp in sorted_timestamps[::-1]:
if instance_started_timestamp >= timestamp or min_timestamp == timestamp:
associated_weights = self.weights[timestamp]
break
if associated_weights is not None:
Expand Down

0 comments on commit 5164c91

Please sign in to comment.