Skip to content

Commit 9d9800c

Browse files
committed
Fix missing updated time on migrated issues and comments
1 parent 1751d5f commit 9d9800c

File tree

6 files changed

+14
-0
lines changed

6 files changed

+14
-0
lines changed

modules/migrations/base/comment.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type Comment struct {
1414
PosterName string
1515
PosterEmail string
1616
Created time.Time
17+
Updated time.Time
1718
Content string
1819
Reactions *Reactions
1920
}

modules/migrations/base/issue.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type Issue struct {
1919
State string // closed, open
2020
IsLocked bool
2121
Created time.Time
22+
Updated time.Time
2223
Closed *time.Time
2324
Labels []*Label
2425
Reactions *Reactions

modules/migrations/base/pullrequest.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type PullRequest struct {
2121
Milestone string
2222
State string
2323
Created time.Time
24+
Updated time.Time
2425
Closed *time.Time
2526
Labels []*Label
2627
PatchURL string

modules/migrations/gitea.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ func (g *GiteaLocalUploader) CreateIssues(issues ...*base.Issue) error {
334334
MilestoneID: milestoneID,
335335
Labels: labels,
336336
CreatedUnix: timeutil.TimeStamp(issue.Created.Unix()),
337+
UpdatedUnix: timeutil.TimeStamp(issue.Updated.Unix()),
337338
}
338339

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

413415
if userid > 0 {
@@ -576,6 +578,7 @@ func (g *GiteaLocalUploader) newPullRequest(pr *base.PullRequest) (*models.PullR
576578
IsLocked: pr.IsLocked,
577579
Labels: labels,
578580
CreatedUnix: timeutil.TimeStamp(pr.Created.Unix()),
581+
UpdatedUnix: timeutil.TimeStamp(pr.Updated.Unix()),
579582
}
580583

581584
userid, ok := g.userMap[pr.PosterID]

modules/migrations/github.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ func (g *GithubDownloaderV3) GetIssues(page, perPage int) ([]*base.Issue, bool,
385385
Milestone: milestone,
386386
State: *issue.State,
387387
Created: *issue.CreatedAt,
388+
Updated: *issue.UpdatedAt,
388389
Labels: labels,
389390
Reactions: reactions,
390391
Closed: issue.ClosedAt,
@@ -428,6 +429,7 @@ func (g *GithubDownloaderV3) GetComments(issueNumber int64) ([]*base.Comment, er
428429
PosterEmail: email,
429430
Content: *comment.Body,
430431
Created: *comment.CreatedAt,
432+
Updated: *comment.UpdatedAt,
431433
Reactions: reactions,
432434
})
433435
}

modules/migrations/github_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
157157
PosterName: "guillep2k",
158158
State: "closed",
159159
Created: time.Date(2019, 11, 9, 17, 0, 29, 0, time.UTC),
160+
Updated: time.Date(2019, 11, 9, 17, 0, 29, 0, time.UTC),
160161
Labels: []*base.Label{
161162
{
162163
Name: "bug",
@@ -189,6 +190,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
189190
PosterName: "mrsdizzie",
190191
State: "closed",
191192
Created: time.Date(2019, 11, 12, 21, 0, 6, 0, time.UTC),
193+
Updated: time.Date(2019, 11, 12, 21, 0, 6, 0, time.UTC),
192194
Labels: []*base.Label{
193195
{
194196
Name: "duplicate",
@@ -219,6 +221,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
219221
PosterID: 1669571,
220222
PosterName: "mrsdizzie",
221223
Created: time.Date(2019, 11, 12, 21, 0, 13, 0, time.UTC),
224+
Updated: time.Date(2019, 11, 12, 21, 0, 13, 0, time.UTC),
222225
Content: "This is a comment",
223226
Reactions: &base.Reactions{
224227
TotalCount: 1,
@@ -235,6 +238,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
235238
PosterID: 1669571,
236239
PosterName: "mrsdizzie",
237240
Created: time.Date(2019, 11, 12, 22, 7, 14, 0, time.UTC),
241+
Updated: time.Date(2019, 11, 12, 22, 7, 14, 0, time.UTC),
238242
Content: "A second comment",
239243
Reactions: &base.Reactions{
240244
TotalCount: 0,
@@ -266,6 +270,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
266270
PosterName: "mrsdizzie",
267271
State: "closed",
268272
Created: time.Date(2019, 11, 12, 21, 21, 43, 0, time.UTC),
273+
Updated: time.Date(2019, 11, 12, 21, 21, 43, 0, time.UTC),
269274
Labels: []*base.Label{
270275
{
271276
Name: "documentation",
@@ -302,6 +307,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
302307
PosterName: "mrsdizzie",
303308
State: "open",
304309
Created: time.Date(2019, 11, 12, 21, 54, 18, 0, time.UTC),
310+
Updated: time.Date(2019, 11, 12, 21, 54, 18, 0, time.UTC),
305311
Labels: []*base.Label{
306312
{
307313
Name: "bug",

0 commit comments

Comments
 (0)