dmitri.shuralyov.com/service/change/...

Improve docs; start on diff inline comments.
dmitshur committed 2 years ago commit cd2816373864bb6d6bfcb2880729493a8046751d
changes.go
@@ -17,11 +17,11 @@ type Service interface {
 	Count(ctx context.Context, repo string, opt ListOptions) (uint64, error)
 
 	// Get a change.
 	Get(ctx context.Context, repo string, id uint64) (Change, error)
 
-	// ListTimeline lists timeline items (changes.Comment, changes.TimelineItem) for specified change id.
+	// ListTimeline lists timeline items (changes.Comment, changes.Review, changes.TimelineItem) for specified change id.
 	ListTimeline(ctx context.Context, repo string, id uint64, opt *ListTimelineOptions) ([]interface{}, error)
 	// ListCommits lists change commits.
 	ListCommits(ctx context.Context, repo string, id uint64) ([]Commit, error)
 	// Get a change diff.
 	GetDiff(ctx context.Context, repo string, id uint64, opt *GetDiffOptions) ([]byte, error)
fs/fs.go
@@ -31,21 +31,39 @@ var s = struct {
 				ID:        1,
 				State:     changes.OpenState,
 				Title:     "Initial implementation of woff2.",
 				Labels:    nil,
 				Author:    shurcool,
-				CreatedAt: time.Now().Add(-5 * time.Minute),
+				CreatedAt: time.Now().UTC().Add(-5 * time.Minute),
 				Replies:   0,
 
 				Commits: 1,
 			},
-			Timeline: nil,
+			Timeline: []interface{}{
+				changes.Review{
+					User:      users.User{Login: "Eric Grosse", AvatarURL: "https://lh6.googleusercontent.com/-_sdEtv2PRxk/AAAAAAAAAAI/AAAAAAAAAAA/aE1Q66Cuvb4/s100-p/photo.jpg"},
+					CreatedAt: time.Now().UTC().Add(-1 * time.Minute),
+					State:     changes.Approved,
+					Comments: []changes.InlineComment{
+						{
+							File: "LICENSE",
+							Line: 26,
+							Body: "Ok by me, but how was this chosen?",
+						},
+						{
+							File: "parse.go",
+							Line: 31,
+							Body: "As someone who reads the server logs, my gut feeling is that 1 QPS of Lookup logs will give me sufficient data to tell me the system is working, without creating a big mess.",
+						},
+					},
+				},
+			},
 			Commits: []changes.Commit{{
 				SHA:        "4a911c4a1eabcc20a66ccc5c983dede401da2796",
 				Message:    "Initial implementation of woff2.\n\nMaybe some additional details here.",
 				Author:     shurcool,
-				AuthorTime: time.Now().Add(-10 * time.Minute),
+				AuthorTime: time.Now().UTC().Add(-10 * time.Minute),
 			}},
 			Diff: []byte(diff),
 		},
 	},
 }
timeline.go
@@ -7,10 +7,11 @@ import (
 	"github.com/shurcooL/reactions"
 	"github.com/shurcooL/users"
 )
 
 // Comment represents a comment left on a change.
+// TODO: Consider removing in favor of Review with commented state and no inline comments.
 type Comment struct {
 	ID        uint64
 	User      users.User
 	CreatedAt time.Time
 	Edited    *Edited // Edited is nil if the comment hasn't been edited.
@@ -23,10 +24,11 @@ type Comment struct {
 type Edited struct {
 	By users.User
 	At time.Time
 }
 
+// Review represents a review left on a change.
 type Review struct {
 	ID        uint64
 	User      users.User
 	CreatedAt time.Time
 	Edited    *Edited // Edited is nil if the review hasn't been edited.
@@ -35,10 +37,11 @@ type Review struct {
 	Reactions []reactions.Reaction
 	Editable  bool // Editable represents whether the current user (if any) can perform edit operations on this review.
 	Comments  []InlineComment
 }
 
+// InlineComment represents an inline comment that was left as part of a review.
 type InlineComment struct {
 	File string
 	Line int
 	Body string
 }