aboutsummaryrefslogtreecommitdiffstats
path: root/cache/bug_excerpt.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2022-11-19 11:33:12 +0100
committerMichael Muré <batolettre@gmail.com>2022-11-28 17:20:25 +0100
commit0ac39a7ab5db077fcf0df827e32bf6e625e980da (patch)
treee453d6fd244cb322bdc6305c0088aa3c0331b075 /cache/bug_excerpt.go
parentc6bb6b9c7ecddb679966b1561e2e909a9ee5e8cd (diff)
downloadgit-bug-0ac39a7ab5db077fcf0df827e32bf6e625e980da.tar.gz
WIP
Diffstat (limited to 'cache/bug_excerpt.go')
-rw-r--r--cache/bug_excerpt.go39
1 files changed, 8 insertions, 31 deletions
diff --git a/cache/bug_excerpt.go b/cache/bug_excerpt.go
index 7e3bcad4..b4748fd2 100644
--- a/cache/bug_excerpt.go
+++ b/cache/bug_excerpt.go
@@ -2,12 +2,10 @@ package cache
import (
"encoding/gob"
- "fmt"
"time"
"github.com/MichaelMure/git-bug/entities/bug"
"github.com/MichaelMure/git-bug/entities/common"
- "github.com/MichaelMure/git-bug/entities/identity"
"github.com/MichaelMure/git-bug/entity"
"github.com/MichaelMure/git-bug/util/lamport"
)
@@ -20,7 +18,7 @@ func init() {
// BugExcerpt hold a subset of the bug values to be able to sort and filter bugs
// efficiently without having to read and compile each raw bugs.
type BugExcerpt struct {
- Id entity.Id
+ id entity.Id
CreateLamportTime lamport.Time
EditLamportTime lamport.Time
@@ -38,25 +36,6 @@ type BugExcerpt struct {
CreateMetadata map[string]string
}
-// identity.Bare data are directly embedded in the bug excerpt
-type LegacyAuthorExcerpt struct {
- Name string
- Login string
-}
-
-func (l LegacyAuthorExcerpt) DisplayName() string {
- switch {
- case l.Name == "" && l.Login != "":
- return l.Login
- case l.Name != "" && l.Login == "":
- return l.Name
- case l.Name != "" && l.Login != "":
- return fmt.Sprintf("%s (%s)", l.Name, l.Login)
- }
-
- panic("invalid person data")
-}
-
func NewBugExcerpt(b bug.Interface, snap *bug.Snapshot) *BugExcerpt {
participantsIds := make([]entity.Id, 0, len(snap.Participants))
for _, participant := range snap.Participants {
@@ -69,11 +48,12 @@ func NewBugExcerpt(b bug.Interface, snap *bug.Snapshot) *BugExcerpt {
}
e := &BugExcerpt{
- Id: b.Id(),
+ id: b.Id(),
CreateLamportTime: b.CreateLamportTime(),
EditLamportTime: b.EditLamportTime(),
CreateUnixTime: b.FirstOp().Time().Unix(),
EditUnixTime: snap.EditTime().Unix(),
+ AuthorId: snap.Author.Id(),
Status: snap.Status,
Labels: snap.Labels,
Actors: actorsIds,
@@ -83,16 +63,13 @@ func NewBugExcerpt(b bug.Interface, snap *bug.Snapshot) *BugExcerpt {
CreateMetadata: b.FirstOp().AllMetadata(),
}
- switch snap.Author.(type) {
- case *identity.Identity, *identity.IdentityStub, *IdentityCache:
- e.AuthorId = snap.Author.Id()
- default:
- panic("unhandled identity type")
- }
-
return e
}
+func (b *BugExcerpt) Id() entity.Id {
+ return b.id
+}
+
func (b *BugExcerpt) CreateTime() time.Time {
return time.Unix(b.CreateUnixTime, 0)
}
@@ -112,7 +89,7 @@ func (b BugsById) Len() int {
}
func (b BugsById) Less(i, j int) bool {
- return b[i].Id < b[j].Id
+ return b[i].id < b[j].id
}
func (b BugsById) Swap(i, j int) {