diff --git a/project_usage_exporter.py b/project_usage_exporter.py index f7d8a33..bef4cfe 100755 --- a/project_usage_exporter.py +++ b/project_usage_exporter.py @@ -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: