aboutsummaryrefslogtreecommitdiffstats
path: root/bug/sorting.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2022-08-18 23:34:05 +0200
committerMichael Muré <batolettre@gmail.com>2022-08-18 23:44:06 +0200
commit5511c230b678a181cc596238bf6669428d1b1902 (patch)
tree8701efc87732439f993eb4f1d00585fc419b87ab /bug/sorting.go
parent5ca686b59751e3c87740b84108c54fc675a074cf (diff)
downloadgit-bug-5511c230b678a181cc596238bf6669428d1b1902.tar.gz
move {bug,identity} to /entities, move input to /commands
Diffstat (limited to 'bug/sorting.go')
-rw-r--r--bug/sorting.go57
1 files changed, 0 insertions, 57 deletions
diff --git a/bug/sorting.go b/bug/sorting.go
deleted file mode 100644
index 2e64b92d..00000000
--- a/bug/sorting.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package bug
-
-type BugsByCreationTime []*Bug
-
-func (b BugsByCreationTime) Len() int {
- return len(b)
-}
-
-func (b BugsByCreationTime) Less(i, j int) bool {
- if b[i].CreateLamportTime() < b[j].CreateLamportTime() {
- return true
- }
-
- if b[i].CreateLamportTime() > b[j].CreateLamportTime() {
- return false
- }
-
- // When the logical clocks are identical, that means we had a concurrent
- // edition. In this case we rely on the timestamp. While the timestamp might
- // be incorrect due to a badly set clock, the drift in sorting is bounded
- // by the first sorting using the logical clock. That means that if users
- // synchronize their bugs regularly, the timestamp will rarely be used, and
- // should still provide a kinda accurate sorting when needed.
- return b[i].FirstOp().Time().Before(b[j].FirstOp().Time())
-}
-
-func (b BugsByCreationTime) Swap(i, j int) {
- b[i], b[j] = b[j], b[i]
-}
-
-type BugsByEditTime []*Bug
-
-func (b BugsByEditTime) Len() int {
- return len(b)
-}
-
-func (b BugsByEditTime) Less(i, j int) bool {
- if b[i].EditLamportTime() < b[j].EditLamportTime() {
- return true
- }
-
- if b[i].EditLamportTime() > b[j].EditLamportTime() {
- return false
- }
-
- // When the logical clocks are identical, that means we had a concurrent
- // edition. In this case we rely on the timestamp. While the timestamp might
- // be incorrect due to a badly set clock, the drift in sorting is bounded
- // by the first sorting using the logical clock. That means that if users
- // synchronize their bugs regularly, the timestamp will rarely be used, and
- // should still provide a kinda accurate sorting when needed.
- return b[i].LastOp().Time().Before(b[j].LastOp().Time())
-}
-
-func (b BugsByEditTime) Swap(i, j int) {
- b[i], b[j] = b[j], b[i]
-}