aboutsummaryrefslogtreecommitdiffstats
path: root/bug
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-06-25 23:18:17 +0200
committerMichael Muré <batolettre@gmail.com>2020-06-25 23:18:17 +0200
commitaab3a04d0c4ddbf97d589ba9048a539c6d7186e9 (patch)
tree5db59215d2c9559c2d33d1a2a2010270a88d669d /bug
parent1d06244c82b18959878cf199cd8dd500bbc46aa7 (diff)
downloadgit-bug-aab3a04d0c4ddbf97d589ba9048a539c6d7186e9.tar.gz
bug: harmonize how time are used, fix some issues in command special formats
This assume that the convertion from time.Time <--> Unix timestamp is lossless which seems to be.
Diffstat (limited to 'bug')
-rw-r--r--bug/op_create.go2
-rw-r--r--bug/op_create_test.go2
-rw-r--r--bug/operation.go14
-rw-r--r--bug/snapshot.go13
4 files changed, 8 insertions, 23 deletions
diff --git a/bug/op_create.go b/bug/op_create.go
index b2af438b..d63d6d2f 100644
--- a/bug/op_create.go
+++ b/bug/op_create.go
@@ -48,7 +48,7 @@ func (op *CreateOperation) Apply(snapshot *Snapshot) {
snapshot.Comments = []Comment{comment}
snapshot.Author = op.Author
- snapshot.CreatedAt = op.Time()
+ snapshot.CreateTime = op.Time()
snapshot.Timeline = []TimelineItem{
&CreateTimelineItem{
diff --git a/bug/op_create_test.go b/bug/op_create_test.go
index ec53b04b..ad9a30fd 100644
--- a/bug/op_create_test.go
+++ b/bug/op_create_test.go
@@ -38,7 +38,7 @@ func TestCreate(t *testing.T) {
Author: rene,
Participants: []identity.Interface{rene},
Actors: []identity.Interface{rene},
- CreatedAt: create.Time(),
+ CreateTime: create.Time(),
Timeline: []TimelineItem{
&CreateTimelineItem{
CommentTimelineItem: NewCommentTimelineItem(id, comment),
diff --git a/bug/operation.go b/bug/operation.go
index 20d44f6c..91df4ef2 100644
--- a/bug/operation.go
+++ b/bug/operation.go
@@ -36,8 +36,6 @@ type Operation interface {
Id() entity.Id
// Time return the time when the operation was added
Time() time.Time
- // GetUnixTime return the unix timestamp when the operation was added
- GetUnixTime() int64
// GetFiles return the files needed by this operation
GetFiles() []git.Hash
// Apply the operation to a Snapshot to create the final state
@@ -89,8 +87,9 @@ func idOperation(op Operation) entity.Id {
type OpBase struct {
OperationType OperationType `json:"type"`
Author identity.Interface `json:"author"`
- UnixTime int64 `json:"timestamp"`
- Metadata map[string]string `json:"metadata,omitempty"`
+ // TODO: part of the data model upgrade, this should eventually be a timestamp + lamport
+ UnixTime int64 `json:"timestamp"`
+ Metadata map[string]string `json:"metadata,omitempty"`
// Not serialized. Store the op's id in memory.
id entity.Id
// Not serialized. Store the extra metadata in memory,
@@ -142,11 +141,6 @@ func (op *OpBase) Time() time.Time {
return time.Unix(op.UnixTime, 0)
}
-// GetUnixTime return the unix timestamp when the operation was added
-func (op *OpBase) GetUnixTime() int64 {
- return op.UnixTime
-}
-
// GetFiles return the files needed by this operation
func (op *OpBase) GetFiles() []git.Hash {
return nil
@@ -158,7 +152,7 @@ func opBaseValidate(op Operation, opType OperationType) error {
return fmt.Errorf("incorrect operation type (expected: %v, actual: %v)", opType, op.base().OperationType)
}
- if op.GetUnixTime() == 0 {
+ if op.Time().Unix() == 0 {
return fmt.Errorf("time not set")
}
diff --git a/bug/snapshot.go b/bug/snapshot.go
index 39366c6d..11df04b2 100644
--- a/bug/snapshot.go
+++ b/bug/snapshot.go
@@ -19,7 +19,7 @@ type Snapshot struct {
Author identity.Interface
Actors []identity.Interface
Participants []identity.Interface
- CreatedAt time.Time
+ CreateTime time.Time
Timeline []TimelineItem
@@ -32,7 +32,7 @@ func (snap *Snapshot) Id() entity.Id {
}
// Return the last time a bug was modified
-func (snap *Snapshot) LastEditTime() time.Time {
+func (snap *Snapshot) EditTime() time.Time {
if len(snap.Operations) == 0 {
return time.Unix(0, 0)
}
@@ -40,15 +40,6 @@ func (snap *Snapshot) LastEditTime() time.Time {
return snap.Operations[len(snap.Operations)-1].Time()
}
-// Return the last timestamp a bug was modified
-func (snap *Snapshot) LastEditUnix() int64 {
- if len(snap.Operations) == 0 {
- return 0
- }
-
- return snap.Operations[len(snap.Operations)-1].GetUnixTime()
-}
-
// GetCreateMetadata return the creation metadata
func (snap *Snapshot) GetCreateMetadata(key string) (string, bool) {
return snap.Operations[0].GetMetadata(key)