From b09f18231230c7b8407b521f3eea39582c6d2444 Mon Sep 17 00:00:00 2001 From: Josh Freda Date: Tue, 5 Mar 2024 15:50:37 -0600 Subject: [PATCH] Reset document created date when publishing a doc (#632) * Fix the field used for Created * Reset document created date when publishing a doc --- internal/api/v2/reviews.go | 6 ++++++ pkg/document/document.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/api/v2/reviews.go b/internal/api/v2/reviews.go index dd23e3ed5..96700f44f 100644 --- a/internal/api/v2/reviews.go +++ b/internal/api/v2/reviews.go @@ -160,6 +160,11 @@ func ReviewsHandler(srv server.Server) http.Handler { return } + // Reset the document creation time to the current time of publish. + now := time.Now() + doc.Created = now.Format("Jan 2, 2006") + doc.CreatedTime = now.Unix() + // Set the document number. nextDocNum := latestNum + 1 doc.DocNumber = fmt.Sprintf("%s-%03d", @@ -459,6 +464,7 @@ func ReviewsHandler(srv server.Server) http.Handler { } return } + d.DocumentCreatedAt = now // Reset to document published time. d.Status = models.InReviewDocumentStatus d.DocumentNumber = nextDocNum d.DocumentModifiedAt = modifiedTime diff --git a/pkg/document/document.go b/pkg/document/document.go index d420c6b9c..f4cbd9c0b 100644 --- a/pkg/document/document.go +++ b/pkg/document/document.go @@ -281,7 +281,7 @@ func NewFromDatabaseModel( doc.Contributors = contributors // Created. - doc.Created = model.CreatedAt.Format("Jan 2, 2006") + doc.Created = model.DocumentCreatedAt.Format("Jan 2, 2006") // CreatedTime. doc.CreatedTime = model.DocumentCreatedAt.Unix()