Skip to content

Commit

Permalink
Merge pull request #1369 from girder/fix-time-compare
Browse files Browse the repository at this point in the history
Fix time comparison in annotation history check
  • Loading branch information
manthey authored Nov 10, 2023
2 parents d2c09f9 + 9276a4c commit 5d54198
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
### Bug Fixes
- Default to "None" for the DICOM assetstore limit ([#1359](../../pull/1359))
- Fix series detection for some bioformats files ([#1365](../../pull/1365), [#1367](../../pull/1367))
- Fix time comparison in annotation history check ([#1369](../../pull/1369))

## 1.26.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ def removeOldAnnotations(self, remove=False, minAgeInDays=30, keepInactiveVersio
keep -= 1
report['recentVersions'] += 1
continue
if max(record['created'], record['updated']) < age:
if max(record['created'], record['updated']).timestamp() < age.timestamp():
if remove:
self.collection.delete_one({'_id': record['_id']})
Annotationelement().removeWithQuery({'_version': record['_version']})
Expand Down
7 changes: 7 additions & 0 deletions girder_annotation/test_annotation/test_annotations_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,13 @@ def testAnnotationHistoryEndpoints(self, server, user, admin):
resp = server.request('/annotation/old', method='GET', user=admin)
assert utilities.respStatus(resp) == 200
assert resp.json['abandonedVersions'] == 0
resp = server.request(
'/annotation/old', method='DELETE', user=admin, params={'versions': -1})
assert utilities.respStatus(resp) == 400
assert 'keepInactiveVersions' in resp.json['message']
resp = server.request(
'/annotation/old', method='GET', user=admin, params={'age': 0, 'versions': 0})
assert utilities.respStatus(resp) == 200
resp = server.request('/annotation/old', method='DELETE', user=admin)
assert utilities.respStatus(resp) == 200
assert resp.json['abandonedVersions'] == 0
Expand Down

0 comments on commit 5d54198

Please sign in to comment.