Skip to content

Commit

Permalink
Fix missing updated time on migrated issues and comments (#9744)
Browse files Browse the repository at this point in the history
* Fix missing updated time on migrated issues and comments

* Fix testing and missing updated on migrating pullrequest

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
  • Loading branch information
2 people authored and zeripath committed Jan 14, 2020
1 parent 2677d07 commit 7f869c0
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/migrations/base/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Comment struct {
PosterName string
PosterEmail string
Created time.Time
Updated time.Time
Content string
Reactions *Reactions
}
1 change: 1 addition & 0 deletions modules/migrations/base/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Issue struct {
State string // closed, open
IsLocked bool
Created time.Time
Updated time.Time
Closed *time.Time
Labels []*Label
Reactions *Reactions
Expand Down
1 change: 1 addition & 0 deletions modules/migrations/base/pullrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type PullRequest struct {
Milestone string
State string
Created time.Time
Updated time.Time
Closed *time.Time
Labels []*Label
PatchURL string
Expand Down
3 changes: 3 additions & 0 deletions modules/migrations/gitea.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ func (g *GiteaLocalUploader) CreateIssues(issues ...*base.Issue) error {
MilestoneID: milestoneID,
Labels: labels,
CreatedUnix: timeutil.TimeStamp(issue.Created.Unix()),
UpdatedUnix: timeutil.TimeStamp(issue.Updated.Unix()),
}

userid, ok := g.userMap[issue.PosterID]
Expand Down Expand Up @@ -408,6 +409,7 @@ func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error {
Type: models.CommentTypeComment,
Content: comment.Content,
CreatedUnix: timeutil.TimeStamp(comment.Created.Unix()),
UpdatedUnix: timeutil.TimeStamp(comment.Updated.Unix()),
}

if userid > 0 {
Expand Down Expand Up @@ -576,6 +578,7 @@ func (g *GiteaLocalUploader) newPullRequest(pr *base.PullRequest) (*models.PullR
IsLocked: pr.IsLocked,
Labels: labels,
CreatedUnix: timeutil.TimeStamp(pr.Created.Unix()),
UpdatedUnix: timeutil.TimeStamp(pr.Updated.Unix()),
}

userid, ok := g.userMap[pr.PosterID]
Expand Down
3 changes: 3 additions & 0 deletions modules/migrations/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ func (g *GithubDownloaderV3) GetIssues(page, perPage int) ([]*base.Issue, bool,
Milestone: milestone,
State: *issue.State,
Created: *issue.CreatedAt,
Updated: *issue.UpdatedAt,
Labels: labels,
Reactions: reactions,
Closed: issue.ClosedAt,
Expand Down Expand Up @@ -428,6 +429,7 @@ func (g *GithubDownloaderV3) GetComments(issueNumber int64) ([]*base.Comment, er
PosterEmail: email,
Content: *comment.Body,
Created: *comment.CreatedAt,
Updated: *comment.UpdatedAt,
Reactions: reactions,
})
}
Expand Down Expand Up @@ -523,6 +525,7 @@ func (g *GithubDownloaderV3) GetPullRequests(page, perPage int) ([]*base.PullReq
Milestone: milestone,
State: *pr.State,
Created: *pr.CreatedAt,
Updated: *pr.UpdatedAt,
Closed: pr.ClosedAt,
Labels: labels,
Merged: merged,
Expand Down
6 changes: 6 additions & 0 deletions modules/migrations/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
PosterName: "guillep2k",
State: "closed",
Created: time.Date(2019, 11, 9, 17, 0, 29, 0, time.UTC),
Updated: time.Date(2019, 11, 12, 20, 29, 53, 0, time.UTC),
Labels: []*base.Label{
{
Name: "bug",
Expand Down Expand Up @@ -189,6 +190,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
PosterName: "mrsdizzie",
State: "closed",
Created: time.Date(2019, 11, 12, 21, 0, 6, 0, time.UTC),
Updated: time.Date(2019, 11, 12, 22, 7, 14, 0, time.UTC),
Labels: []*base.Label{
{
Name: "duplicate",
Expand Down Expand Up @@ -219,6 +221,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
PosterID: 1669571,
PosterName: "mrsdizzie",
Created: time.Date(2019, 11, 12, 21, 0, 13, 0, time.UTC),
Updated: time.Date(2019, 11, 12, 21, 0, 13, 0, time.UTC),
Content: "This is a comment",
Reactions: &base.Reactions{
TotalCount: 1,
Expand All @@ -235,6 +238,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
PosterID: 1669571,
PosterName: "mrsdizzie",
Created: time.Date(2019, 11, 12, 22, 7, 14, 0, time.UTC),
Updated: time.Date(2019, 11, 12, 22, 7, 14, 0, time.UTC),
Content: "A second comment",
Reactions: &base.Reactions{
TotalCount: 0,
Expand Down Expand Up @@ -266,6 +270,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
PosterName: "mrsdizzie",
State: "closed",
Created: time.Date(2019, 11, 12, 21, 21, 43, 0, time.UTC),
Updated: time.Date(2019, 11, 12, 21, 39, 28, 0, time.UTC),
Labels: []*base.Label{
{
Name: "documentation",
Expand Down Expand Up @@ -302,6 +307,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
PosterName: "mrsdizzie",
State: "open",
Created: time.Date(2019, 11, 12, 21, 54, 18, 0, time.UTC),
Updated: time.Date(2020, 1, 4, 11, 30, 1, 0, time.UTC),
Labels: []*base.Label{
{
Name: "bug",
Expand Down

0 comments on commit 7f869c0

Please sign in to comment.