Skip to content

Commit

Permalink
better stat sorting.
Browse files Browse the repository at this point in the history
  • Loading branch information
anarkiwi committed Jan 8, 2024
1 parent df51cf9 commit 9387802
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions gamutrfwaterfall/gamutrfwaterfall/waterfall.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,18 +1098,20 @@ def serve(self, path):

def serve_predictions(self):
if self.predictions_path and self.predictions:
predictions = sorted(glob.glob(self.predictions_path, recursive=True))[
-self.predictions :
]
predictions = sorted(

Check warning on line 1101 in gamutrfwaterfall/gamutrfwaterfall/waterfall.py

View check run for this annotation

Codecov / codecov/patch

gamutrfwaterfall/gamutrfwaterfall/waterfall.py#L1100-L1101

Added lines #L1100 - L1101 were not covered by tests
[
(os.stat(prediction).st_ctime, prediction)
for prediction in glob.glob(self.predictions_path, recursive=True)
]
)[-self.predictions :]
if not predictions:
return "no recent predictions at %s" % self.predictions_path, 200
images = []
now = time.time()
for prediction in predictions:
stat = os.stat(prediction)
for ctime, prediction in sorted(predictions, reverse=True):
images.append(

Check warning on line 1112 in gamutrfwaterfall/gamutrfwaterfall/waterfall.py

View check run for this annotation

Codecov / codecov/patch

gamutrfwaterfall/gamutrfwaterfall/waterfall.py#L1107-L1112

Added lines #L1107 - L1112 were not covered by tests
"%s (age %.1fs)<p><img src=%s></img></p>"
% (prediction, now - stat.st_ctime, prediction)
% (prediction, now - ctime, prediction)
)
content = (

Check warning on line 1116 in gamutrfwaterfall/gamutrfwaterfall/waterfall.py

View check run for this annotation

Codecov / codecov/patch

gamutrfwaterfall/gamutrfwaterfall/waterfall.py#L1116

Added line #L1116 was not covered by tests
'<html><head><meta http-equiv="refresh" content="%u"></head><body>%s</body></html>'
Expand Down

0 comments on commit 9387802

Please sign in to comment.