From 0a716e756cd53a1558e8dbba990da113a9bb4738 Mon Sep 17 00:00:00 2001 From: Florian M Date: Thu, 17 Sep 2020 13:41:22 +0200 Subject: [PATCH 1/3] drop overlaps when saving timespans --- app/models/user/time/TimeSpanService.scala | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/models/user/time/TimeSpanService.scala b/app/models/user/time/TimeSpanService.scala index 7eb6dc6e63..90da495264 100644 --- a/app/models/user/time/TimeSpanService.scala +++ b/app/models/user/time/TimeSpanService.scala @@ -117,11 +117,15 @@ class TimeSpanService @Inject()(annotationDAO: AnnotationDAO, } def updateTimeSpan(timeSpan: TimeSpan, timestamp: Long) = { - timeSpansToUpdate = (timeSpan, timestamp) :: timeSpansToUpdate - val duration = timestamp - timeSpan.lastUpdate - val updated = timeSpan.addTime(duration, timestamp) - updated + if (duration >= 0) { + timeSpansToUpdate = (timeSpan, timestamp) :: timeSpansToUpdate + timeSpan.addTime(duration, timestamp) + } else { + logger.info( + s"Not updating previous timespan due to negative duration ${duration} for user ${timeSpan._id}, last timespan id ${timeSpan._id}, this=${this}") + timeSpan + } } var current = lastUserActivities @@ -155,7 +159,10 @@ class TimeSpanService @Inject()(annotationDAO: AnnotationDAO, private def isNotInterrupted(current: Long, last: TimeSpan) = { val duration = current - last.lastUpdate - duration >= 0 && duration < MaxTracingPause + if (duration < 0) { + logger.warn(s"Negative timespan duration to previous entry.") + } + duration < MaxTracingPause } private def belongsToSameTracing(last: TimeSpan, annotation: Option[Annotation]) = From 9842ee3d175394239b245a4626ecb806ec9f2928 Mon Sep 17 00:00:00 2001 From: Florian M Date: Thu, 17 Sep 2020 14:31:44 +0200 Subject: [PATCH 2/3] changelog --- CHANGELOG.released.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.released.md b/CHANGELOG.released.md index 980f037c59..cb6e59ec77 100644 --- a/CHANGELOG.released.md +++ b/CHANGELOG.released.md @@ -35,6 +35,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released - Speed up NML import in existing tracings for NMLs with many trees (20,000+). [#4742](https://github.com/scalableminds/webknossos/pull/4742) - Fixed tree groups when uploading NMLs with multi-component trees. [#4735](https://github.com/scalableminds/webknossos/pull/4735) - Fixed that invalid number values in slider settings could crash webKnossos. [#4758](https://github.com/scalableminds/webknossos/pull/4758) +- Improved resilience in time tracking, preventing overlapping timespans. [#4830](https://github.com/scalableminds/webknossos/pull/4830) ## [20.08.0](https://github.com/scalableminds/webknossos/releases/tag/20.08.0) - 2020-07-20 [Commits](https://github.com/scalableminds/webknossos/compare/20.07.0...20.08.0) @@ -127,13 +128,13 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released - Added support for ID mapping of segmentation layer based on HDF5 agglomerate files. [#4469](https://github.com/scalableminds/webknossos/pull/4469) - Added option to hide all unmapped segments to segmentation tab. [#4510](https://github.com/scalableminds/webknossos/pull/4510) - It is now possible to upload volume tracings as a base for tasks. The upload format is similar to the project / task type download format. [#4565](https://github.com/scalableminds/webknossos/pull/4565) -- Added the possibility to share the dataset which is currently viewed (using a private token if the dataset is not public). The option can be found in the dropdown of the navigation bar. [#4543](https://github.com/scalableminds/webknossos/pull/4543) +- Added the possibility to share the dataset which is currently viewed (using a private token if the dataset is not public). The option can be found in the dropdown of the navigation bar. [#4543](https://github.com/scalableminds/webknossos/pull/4543) ### Added - Users can undo finishing a task when the task was finished via the API, e.g. by a user script. [#4495](https://github.com/scalableminds/webknossos/pull/4495) - Added the magnification used for determining the segment ids in the segmentation tab to the table of the tab. [#4480](https://github.com/scalableminds/webknossos/pull/4480) - Added support for ID mapping of segmentation layer based on HDF5 agglomerate files. [#4469](https://github.com/scalableminds/webknossos/pull/4469) -- Added the possibility to share the dataset which is currently viewed (using a private token if the dataset is not public). The option can be found in the dropdown of the navigation bar. [#4543](https://github.com/scalableminds/webknossos/pull/4543) +- Added the possibility to share the dataset which is currently viewed (using a private token if the dataset is not public). The option can be found in the dropdown of the navigation bar. [#4543](https://github.com/scalableminds/webknossos/pull/4543) - Added option to hide all unmapped segments to segmentation tab. [#4510](https://github.com/scalableminds/webknossos/pull/4510) - When wK changes datasource-properties.json files of datasets, now it creates a backup log of previous versions. [#4534](https://github.com/scalableminds/webknossos/pull/4534) - Added a warning to the position input in tracings if the current position is out of bounds. The warning colors the position input orange. [#4544](https://github.com/scalableminds/webknossos/pull/4544) From 82fc309395927791823433c9e16bc77f1b9382a8 Mon Sep 17 00:00:00 2001 From: Florian M Date: Thu, 17 Sep 2020 14:32:55 +0200 Subject: [PATCH 3/3] Update TimeSpanService.scala --- app/models/user/time/TimeSpanService.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user/time/TimeSpanService.scala b/app/models/user/time/TimeSpanService.scala index 90da495264..99e1f68fe4 100644 --- a/app/models/user/time/TimeSpanService.scala +++ b/app/models/user/time/TimeSpanService.scala @@ -122,7 +122,7 @@ class TimeSpanService @Inject()(annotationDAO: AnnotationDAO, timeSpansToUpdate = (timeSpan, timestamp) :: timeSpansToUpdate timeSpan.addTime(duration, timestamp) } else { - logger.info( + logger.warn( s"Not updating previous timespan due to negative duration ${duration} for user ${timeSpan._id}, last timespan id ${timeSpan._id}, this=${this}") timeSpan }