Open platform to collect and prioritize feedback
refactor: rename _on to _at (#537)
Guilherme Oenning3d4e74bb37be
diff --git a/app/handlers/common.go b/app/handlers/common.goindex 69031b537..a2b457303 100644--- a/app/handlers/common.go+++ b/app/handlers/common.go@@ -70,12 +70,12 @@ func validateKey(kind models.EmailVerificationKind, c web.Context) (*models.Emai}//If key has been used, return Gone- if result.VerifiedOn != nil {+ if result.VerifiedAt != nil {return nil, c.Gone()}//If key expired, return Gone- if time.Now().After(result.ExpiresOn) {+ if time.Now().After(result.ExpiresAt) {err = c.Services().Tenants.SetKeyAsVerified(key)if err != nil {return nil, c.Failure(err)diff --git a/app/handlers/settings_test.go b/app/handlers/settings_test.goindex c93669d17..9d234b0e6 100644--- a/app/handlers/settings_test.go+++ b/app/handlers/settings_test.go@@ -158,7 +158,7 @@ func TestVerifyChangeEmailKeyHandler_Success(t *testing.T) {result, err := services.Tenants.FindVerificationByKey(models.EmailVerificationKindChangeEmail, "th3-s3cr3t")Expect(err).IsNil()- Expect(result.VerifiedOn).IsNotNil()+ Expect(result.VerifiedAt).IsNotNil()}func TestVerifyChangeEmailKeyHandler_DifferentUser(t *testing.T) {diff --git a/app/handlers/signin_test.go b/app/handlers/signin_test.goindex 0f53bf3a1..14fb83b91 100644--- a/app/handlers/signin_test.go+++ b/app/handlers/signin_test.go@@ -73,7 +73,7 @@ func TestVerifySignInKeyHandler_ExpiredKey(t *testing.T) {e := &models.SignInByEmail{Email: "[email protected]"}services.Tenants.SaveVerificationKey("1234567890", 5*time.Minute, e)request, _ := services.Tenants.FindVerificationByKey(models.EmailVerificationKindSignIn, "1234567890")- request.ExpiresOn = request.CreatedOn.Add(-6 * time.Minute) //reduce 1 minute+ request.ExpiresAt = request.CreatedAt.Add(-6 * time.Minute) //reduce 1 minutecode, _ := server.OnTenant(mock.DemoTenant).@@ -273,7 +273,7 @@ func TestCompleteSignInProfileHandler_CorrectKey(t *testing.T) {request, err := services.Tenants.FindVerificationByKey(models.EmailVerificationKindSignIn, "1234567890")Expect(err).IsNil()- Expect(request.VerifiedOn).IsNotNil()+ Expect(request.VerifiedAt).IsNotNil()}func TestSignInPageHandler_AuthenticatedUser(t *testing.T) {diff --git a/app/models/feedback.go b/app/models/feedback.goindex 6c8fdcad6..5663e436d 100644--- a/app/models/feedback.go+++ b/app/models/feedback.go@@ -12,7 +12,7 @@ type Post struct {Title string `json:"title"`Slug string `json:"slug"`Description string `json:"description"`- CreatedOn time.Time `json:"createdOn"`+ CreatedAt time.Time `json:"createdAt"`User *User `json:"user"`HasVoted bool `json:"hasVoted"`TotalVotes int `json:"totalVotes"`@@ -70,7 +70,7 @@ type SetResponse struct {//PostResponse is a staff response to a given posttype PostResponse struct {Text string `json:"text"`- RespondedOn time.Time `json:"respondedOn"`+ RespondedAt time.Time `json:"respondedAt"`User *User `json:"user"`Original *OriginalPost `json:"original"`}@@ -87,9 +87,9 @@ type OriginalPost struct {type Comment struct {ID int `json:"id"`Content string `json:"content"`- CreatedOn time.Time `json:"createdOn"`+ CreatedAt time.Time `json:"createdAt"`User *User `json:"user"`- EditedOn *time.Time `json:"editedOn"`+ EditedAt *time.Time `json:"editedAt"`EditedBy *User `json:"editedBy"`}diff --git a/app/models/identity.go b/app/models/identity.goindex 44f32c69e..53b051fc0 100644--- a/app/models/identity.go+++ b/app/models/identity.go@@ -286,9 +286,9 @@ type EmailVerification struct {Key stringUserID intKind EmailVerificationKind- CreatedOn time.Time- ExpiresOn time.Time- VerifiedOn *time.Time+ CreatedAt time.Time+ ExpiresAt time.Time+ VerifiedAt *time.Time}// CompleteProfile is the model used to complete user profile during email sign indiff --git a/app/models/infra.go b/app/models/infra.goindex 12cc808ea..2b1335569 100644--- a/app/models/infra.go+++ b/app/models/infra.go@@ -23,7 +23,7 @@ type Notification struct {Title string `json:"title" db:"title"`Link string `json:"link" db:"link"`Read bool `json:"read" db:"read"`- CreatedOn time.Time `json:"createdOn" db:"created_on"`+ CreatedAt time.Time `json:"createdAt" db:"created_at"`}// CreateEditOAuthConfig is used to create/edit an OAuth Configurationdiff --git a/app/pkg/csv/csv.go b/app/pkg/csv/csv.goindex a07a81057..0eb10721a 100644--- a/app/pkg/csv/csv.go+++ b/app/pkg/csv/csv.go@@ -19,13 +19,13 @@ func FromPosts(posts []*models.Post) ([]byte, error) {"number","title","description",- "created_on",+ "created_at","created_by","total_votes","total_comments","status","responded_by",- "responded_on",+ "responded_at","response","original_number","original_title",@@ -40,13 +40,13 @@ func FromPosts(posts []*models.Post) ([]byte, error) {originalNumber stringoriginalTitle stringrespondedBy string- respondedOn string+ respondedAt stringresponse string)if post.Response != nil {respondedBy = post.Response.User.Name- respondedOn = post.Response.RespondedOn.Format(time.RFC3339)+ respondedAt = post.Response.RespondedAt.Format(time.RFC3339)response = post.Response.Textif post.Response.Original != nil {originalNumber = strconv.Itoa(post.Response.Original.Number)@@ -58,13 +58,13 @@ func FromPosts(posts []*models.Post) ([]byte, error) {strconv.Itoa(post.Number),post.Title,post.Description,- post.CreatedOn.Format(time.RFC3339),+ post.CreatedAt.Format(time.RFC3339),post.User.Name,strconv.Itoa(post.TotalVotes),strconv.Itoa(post.TotalComments),models.GetPostStatusName(post.Status),respondedBy,- respondedOn,+ respondedAt,response,originalNumber,originalTitle,diff --git a/app/pkg/csv/csv_test.go b/app/pkg/csv/csv_test.goindex 5a2e7d61f..b8e2db64f 100644--- a/app/pkg/csv/csv_test.go+++ b/app/pkg/csv/csv_test.go@@ -55,7 +55,7 @@ var declinedPost = &models.Post{Number: 10,Title: "Go is fast",Description: "Very tiny description",- CreatedOn: time.Date(2018, 3, 23, 19, 33, 22, 0, time.UTC),+ CreatedAt: time.Date(2018, 3, 23, 19, 33, 22, 0, time.UTC),User: &models.User{Name: "Faceless",},@@ -64,7 +64,7 @@ var declinedPost = &models.Post{Status: models.PostDeclined,Response: &models.PostResponse{Text: "Nothing we need to do",- RespondedOn: time.Date(2018, 4, 4, 19, 48, 10, 0, time.UTC),+ RespondedAt: time.Date(2018, 4, 4, 19, 48, 10, 0, time.UTC),User: &models.User{Name: "John Snow",},@@ -76,7 +76,7 @@ var openPost = &models.Post{Number: 15,Title: "Go is great",Description: "",- CreatedOn: time.Date(2018, 2, 21, 15, 51, 35, 0, time.UTC),+ CreatedAt: time.Date(2018, 2, 21, 15, 51, 35, 0, time.UTC),User: &models.User{Name: "Someone else",},@@ -89,7 +89,7 @@ var duplicatePost = &models.Post{Number: 20,Title: "Go is easy",Description: "",- CreatedOn: time.Date(2018, 1, 12, 1, 46, 59, 0, time.UTC),+ CreatedAt: time.Date(2018, 1, 12, 1, 46, 59, 0, time.UTC),User: &models.User{Name: "Faceless",},@@ -98,7 +98,7 @@ var duplicatePost = &models.Post{Status: models.PostDuplicate,Response: &models.PostResponse{Text: "This has already been suggested",- RespondedOn: time.Date(2018, 3, 17, 10, 15, 42, 0, time.UTC),+ RespondedAt: time.Date(2018, 3, 17, 10, 15, 42, 0, time.UTC),User: &models.User{Name: "Arya Stark",},diff --git a/app/pkg/csv/testdata/empty.csv b/app/pkg/csv/testdata/empty.csvindex 4da6c3c7b..908f59f34 100644--- a/app/pkg/csv/testdata/empty.csv+++ b/app/pkg/csv/testdata/empty.csv@@ -1 +1 @@-number,title,description,created_on,created_by,total_votes,total_comments,status,responded_by,responded_on,response,original_number,original_title,tags+number,title,description,created_at,created_by,total_votes,total_comments,status,responded_by,responded_at,response,original_number,original_title,tagsdiff --git a/app/pkg/csv/testdata/more-posts.csv b/app/pkg/csv/testdata/more-posts.csvindex 82bebfaa0..b789b011d 100755--- a/app/pkg/csv/testdata/more-posts.csv+++ b/app/pkg/csv/testdata/more-posts.csv@@ -1,4 +1,4 @@-number,title,description,created_on,created_by,total_votes,total_comments,status,responded_by,responded_on,response,original_number,original_title,tags+number,title,description,created_at,created_by,total_votes,total_comments,status,responded_by,responded_at,response,original_number,original_title,tags10,Go is fast,Very tiny description,2018-03-23T19:33:22Z,Faceless,4,2,Declined,John Snow,2018-04-04T19:48:10Z,Nothing we need to do,,,"easy, ignored"15,Go is great,,2018-02-21T15:51:35Z,Someone else,4,2,Open,,,,,,20,Go is easy,,2018-01-12T01:46:59Z,Faceless,4,2,Duplicate,Arya Stark,2018-03-17T10:15:42Z,This has already been suggested,99,Go is very easy,"this-tag-has,comma"diff --git a/app/pkg/csv/testdata/one-post.csv b/app/pkg/csv/testdata/one-post.csvindex 82355dd4c..b782067bc 100755--- a/app/pkg/csv/testdata/one-post.csv+++ b/app/pkg/csv/testdata/one-post.csv@@ -1,2 +1,2 @@-number,title,description,created_on,created_by,total_votes,total_comments,status,responded_by,responded_on,response,original_number,original_title,tags+number,title,description,created_at,created_by,total_votes,total_comments,status,responded_by,responded_at,response,original_number,original_title,tags10,Go is fast,Very tiny description,2018-03-23T19:33:22Z,Faceless,4,2,Declined,John Snow,2018-04-04T19:48:10Z,Nothing we need to do,,,"easy, ignored"diff --git a/app/pkg/dbx/setup.sql b/app/pkg/dbx/setup.sqlindex ac9659de9..b033bd93d 100644--- a/app/pkg/dbx/setup.sql+++ b/app/pkg/dbx/setup.sql@@ -1,31 +1,31 @@TRUNCATE TABLE logs RESTART IDENTITY CASCADE;TRUNCATE TABLE tenants RESTART IDENTITY CASCADE;-INSERT INTO tenants (name, subdomain, created_on, cname, invitation, welcome_message, status, is_private, custom_css)+INSERT INTO tenants (name, subdomain, created_at, cname, invitation, welcome_message, status, is_private, custom_css)VALUES ('Demonstration', 'demo', now(), '', '', '', 1, false, '');-INSERT INTO users (name, email, tenant_id, created_on, role, status)+INSERT INTO users (name, email, tenant_id, created_at, role, status)VALUES ('Jon Snow', '[email protected]', 1, now(), 3, 1);-INSERT INTO user_providers (user_id, tenant_id, provider, provider_uid, created_on)+INSERT INTO user_providers (user_id, tenant_id, provider, provider_uid, created_at)VALUES (1, 1, 'facebook', 'FB1234', now());-INSERT INTO users (name, email, tenant_id, created_on, role, status)+INSERT INTO users (name, email, tenant_id, created_at, role, status)VALUES ('Arya Stark', '[email protected]', 1, now(), 1, 1);-INSERT INTO user_providers (user_id, tenant_id, provider, provider_uid, created_on)+INSERT INTO user_providers (user_id, tenant_id, provider, provider_uid, created_at)VALUES (2, 1, 'google', 'GO5678', now());-INSERT INTO users (name, email, tenant_id, created_on, role, status)+INSERT INTO users (name, email, tenant_id, created_at, role, status)VALUES ('Sansa Stark', '[email protected]', 1, now(), 1, 1);-INSERT INTO tenants (name, subdomain, created_on, cname, invitation, welcome_message, status, is_private, custom_css)+INSERT INTO tenants (name, subdomain, created_at, cname, invitation, welcome_message, status, is_private, custom_css)VALUES ('Avengers', 'avengers', now(), 'feedback.avengers.com', '', '', 1, false, '');-INSERT INTO users (name, email, tenant_id, created_on, role, status)+INSERT INTO users (name, email, tenant_id, created_at, role, status)VALUES ('Tony Stark', '[email protected]', 2, now(), 3, 1);-INSERT INTO user_providers (user_id, tenant_id, provider, provider_uid, created_on)+INSERT INTO user_providers (user_id, tenant_id, provider, provider_uid, created_at)VALUES (4, 2, 'facebook', 'FB2222', now());-INSERT INTO users (name, email, tenant_id, created_on, role, status)+INSERT INTO users (name, email, tenant_id, created_at, role, status)VALUES ('The Hulk', '[email protected]', 2, now(), 1, 1);-INSERT INTO user_providers (user_id, tenant_id, provider, provider_uid, created_on)+INSERT INTO user_providers (user_id, tenant_id, provider, provider_uid, created_at)VALUES (5, 2, 'google', 'GO1111', now());diff --git a/app/pkg/log/database/logger.go b/app/pkg/log/database/logger.goindex ac6775bb9..7314e2934 100644--- a/app/pkg/log/database/logger.go+++ b/app/pkg/log/database/logger.go@@ -131,7 +131,7 @@ func (l *Logger) log(level log.Level, message string, props log.Props) {message = log.Parse(message, props, false)_, err = trx.Execute(- "INSERT INTO logs (tag, level, text, created_on, properties) VALUES ($1, $2, $3, $4, $5)",+ "INSERT INTO logs (tag, level, text, created_at, properties) VALUES ($1, $2, $3, $4, $5)",l.tag, level.String(), message, time.Now(), props,)diff --git a/app/pkg/web/context.go b/app/pkg/web/context.goindex 4b934356b..175482033 100644--- a/app/pkg/web/context.go+++ b/app/pkg/web/context.go@@ -160,6 +160,9 @@ func (ctx *Context) SetTenant(tenant *models.Tenant) {func (ctx *Context) BindTo(i actions.Actionable) *validate.Result {err := ctx.engine.binder.Bind(i.Initialize(), ctx)if err != nil {+ if err == ErrContentTypeNotAllowed {+ return validate.Failed(err.Error())+ }return validate.Error(errors.Wrap(err, "failed to bind request to action"))}if !i.IsAuthorized(ctx.User(), ctx.Services()) {diff --git a/app/storage/inmemory/notifications.go b/app/storage/inmemory/notifications.goindex c2dab9741..dcaecdc91 100644--- a/app/storage/inmemory/notifications.go+++ b/app/storage/inmemory/notifications.go@@ -41,7 +41,7 @@ func (s *NotificationStorage) Insert(user *models.User, title, link string, postTitle: title,Link: link,Read: false,- CreatedOn: time.Now(),+ CreatedAt: time.Now(),}all, ok := s.notifications[user]if !ok {diff --git a/app/storage/inmemory/post.go b/app/storage/inmemory/post.goindex 8d259d2bc..e7737d3cb 100644--- a/app/storage/inmemory/post.go+++ b/app/storage/inmemory/post.go@@ -121,7 +121,7 @@ func (s *PostStorage) AddComment(post *models.Post, content string) (int, error)s.postComments[post.ID] = append(s.postComments[post.ID], &models.Comment{ID: s.lastCommentID,Content: content,- CreatedOn: time.Now(),+ CreatedAt: time.Now(),User: s.user,})@@ -148,7 +148,7 @@ func (s *PostStorage) UpdateComment(id int, content string) error {return err}comment.Content = content- comment.EditedOn = &now+ comment.EditedAt = &nowcomment.EditedBy = s.userreturn nil}@@ -183,7 +183,7 @@ func (s *PostStorage) SetResponse(post *models.Post, text string, status int) erstoredPost.Response = &models.PostResponse{Text: text,User: s.user,- RespondedOn: time.Now(),+ RespondedAt: time.Now(),}}}@@ -203,7 +203,7 @@ func (s *PostStorage) MarkAsDuplicate(post *models.Post, original *models.Post)},Text: "",User: s.user,- RespondedOn: time.Now(),+ RespondedAt: time.Now(),}return nil}diff --git a/app/storage/inmemory/tenant.go b/app/storage/inmemory/tenant.goindex 20e048cb5..6a52ac727 100644--- a/app/storage/inmemory/tenant.go+++ b/app/storage/inmemory/tenant.go@@ -162,9 +162,9 @@ func (s *TenantStorage) SaveVerificationKey(key string, duration time.Duration,Kind: request.GetKind(),Key: key,UserID: userID,- CreatedOn: time.Now(),- ExpiresOn: time.Now().Add(duration),- VerifiedOn: nil,+ CreatedAt: time.Now(),+ ExpiresAt: time.Now().Add(duration),+ VerifiedAt: nil,})return nil}@@ -184,7 +184,7 @@ func (s *TenantStorage) SetKeyAsVerified(key string) error {for _, verification := range s.verifications {if verification.Key == key {now := time.Now()- verification.VerifiedOn = &now+ verification.VerifiedAt = &now}}return nildiff --git a/app/storage/postgres/common.go b/app/storage/postgres/common.goindex 2163e1bb8..41307ad68 100644--- a/app/storage/postgres/common.go+++ b/app/storage/postgres/common.go@@ -60,7 +60,7 @@ func getFilterData(filter string) (string, []int, string) {case "trending":fallthroughdefault:- sort = "((COALESCE(recent_votes, 0)*5 + COALESCE(recent_comments, 0) *3)-1) / pow((EXTRACT(EPOCH FROM current_timestamp - created_on)/3600) + 2, 1.4)"+ sort = "((COALESCE(recent_votes, 0)*5 + COALESCE(recent_comments, 0) *3)-1) / pow((EXTRACT(EPOCH FROM current_timestamp - created_at)/3600) + 2, 1.4)"}return condition, statuses, sort}diff --git a/app/storage/postgres/notifications.go b/app/storage/postgres/notifications.goindex dc5b06e90..8487c8d77 100644--- a/app/storage/postgres/notifications.go+++ b/app/storage/postgres/notifications.go@@ -42,11 +42,11 @@ func (s *NotificationStorage) Insert(user *models.User, title, link string, postnotification := &models.Notification{Title: title,Link: link,- CreatedOn: now,+ CreatedAt: now,Read: false,}err := s.trx.Get(¬ification.ID, `- INSERT INTO notifications (tenant_id, user_id, title, link, read, post_id, author_id, created_on, updated_on)+ INSERT INTO notifications (tenant_id, user_id, title, link, read, post_id, author_id, created_at, updated_at)VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $8)RETURNING id`, s.tenant.ID, user.ID, title, link, false, postID, s.user.ID, now)@@ -74,7 +74,7 @@ func (s *NotificationStorage) MarkAsRead(id int) error {return nil}_, err := s.trx.Execute(`- UPDATE notifications SET read = true, updated_on = $1+ UPDATE notifications SET read = true, updated_at = $1WHERE id = $2 AND tenant_id = $3 AND user_id = $4 AND read = false`, time.Now(), id, s.tenant.ID, s.user.ID)if err != nil {@@ -89,7 +89,7 @@ func (s *NotificationStorage) MarkAllAsRead() error {return nil}_, err := s.trx.Execute(`- UPDATE notifications SET read = true, updated_on = $1+ UPDATE notifications SET read = true, updated_at = $1WHERE tenant_id = $2 AND user_id = $3 AND read = false`, time.Now(), s.tenant.ID, s.user.ID)if err != nil {@@ -102,10 +102,10 @@ func (s *NotificationStorage) MarkAllAsRead() error {func (s *NotificationStorage) GetActiveNotifications() ([]*models.Notification, error) {notifications := []*models.Notification{}err := s.trx.Select(¬ifications, `- SELECT id, title, link, read, created_on+ SELECT id, title, link, read, created_atFROM notificationsWHERE tenant_id = $1 AND user_id = $2- AND (read = false OR updated_on > CURRENT_DATE - INTERVAL '30 days')+ AND (read = false OR updated_at > CURRENT_DATE - INTERVAL '30 days')`, s.tenant.ID, s.user.ID)if err != nil {return nil, errors.Wrap(err, "failed to get active notifications")@@ -117,7 +117,7 @@ func (s *NotificationStorage) GetActiveNotifications() ([]*models.Notification,func (s *NotificationStorage) GetNotification(id int) (*models.Notification, error) {notification := &models.Notification{}err := s.trx.Get(notification, `- SELECT id, title, link, read, created_on+ SELECT id, title, link, read, created_atFROM notificationsWHERE id = $1 AND tenant_id = $2 AND user_id = $3`, id, s.tenant.ID, s.user.ID)diff --git a/app/storage/postgres/notifications_test.go b/app/storage/postgres/notifications_test.goindex a91e33bb5..129d32d5a 100644--- a/app/storage/postgres/notifications_test.go+++ b/app/storage/postgres/notifications_test.go@@ -78,7 +78,7 @@ func TestNotificationStorage_GetActiveNotifications(t *testing.T) {notifications.MarkAsRead(allNotifications[0].ID)notifications.MarkAsRead(allNotifications[1].ID)- trx.Execute("UPDATE notifications SET updated_on = $1 WHERE id = $2", time.Now().AddDate(0, 0, -31), allNotifications[0].ID)+ trx.Execute("UPDATE notifications SET updated_at = $1 WHERE id = $2", time.Now().AddDate(0, 0, -31), allNotifications[0].ID)allNotifications, err = notifications.GetActiveNotifications()Expect(err).IsNil()diff --git a/app/storage/postgres/post.go b/app/storage/postgres/post.goindex a4940983f..dd3bdca87 100644--- a/app/storage/postgres/post.go+++ b/app/storage/postgres/post.go@@ -20,7 +20,7 @@ type dbPost struct {Title string `db:"title"`Slug string `db:"slug"`Description string `db:"description"`- CreatedOn time.Time `db:"created_on"`+ CreatedAt time.Time `db:"created_at"`User *dbUser `db:"user"`HasVoted bool `db:"has_voted"`TotalVotes int `db:"votes"`@@ -29,7 +29,7 @@ type dbPost struct {RecentComments int `db:"recent_comments"`Status int `db:"status"`Response sql.NullString `db:"response"`- RespondedOn dbx.NullTime `db:"response_date"`+ RespondedAt dbx.NullTime `db:"response_date"`ResponseUser *dbUser `db:"response_user"`OriginalNumber sql.NullInt64 `db:"original_number"`OriginalTitle sql.NullString `db:"original_title"`@@ -45,7 +45,7 @@ func (i *dbPost) toModel() *models.Post {Title: i.Title,Slug: i.Slug,Description: i.Description,- CreatedOn: i.CreatedOn,+ CreatedAt: i.CreatedAt,HasVoted: i.HasVoted,TotalVotes: i.TotalVotes,TotalComments: i.TotalComments,@@ -57,7 +57,7 @@ func (i *dbPost) toModel() *models.Post {if i.Response.Valid {post.Response = &models.PostResponse{Text: i.Response.String,- RespondedOn: i.RespondedOn.Time,+ RespondedAt: i.RespondedAt.Time,User: i.ResponseUser.toModel(),}if post.Status == models.PostDuplicate && i.OriginalNumber.Valid {@@ -75,9 +75,9 @@ func (i *dbPost) toModel() *models.Post {type dbComment struct {ID int `db:"id"`Content string `db:"content"`- CreatedOn time.Time `db:"created_on"`+ CreatedAt time.Time `db:"created_at"`User *dbUser `db:"user"`- EditedOn dbx.NullTime `db:"edited_on"`+ EditedAt dbx.NullTime `db:"edited_at"`EditedBy *dbUser `db:"edited_by"`}@@ -85,12 +85,12 @@ func (c *dbComment) toModel() *models.Comment {comment := &models.Comment{ID: c.ID,Content: c.Content,- CreatedOn: c.CreatedOn,+ CreatedAt: c.CreatedAt,User: c.User.toModel(),}- if c.EditedOn.Valid {+ if c.EditedAt.Valid {comment.EditedBy = c.EditedBy.toModel()- comment.EditedOn = &c.EditedOn.Time+ comment.EditedAt = &c.EditedAt.Time}return comment}@@ -129,7 +129,7 @@ var (agg_comments AS (SELECTpost_id,- COUNT(CASE WHEN comments.created_on > CURRENT_DATE - INTERVAL '30 days' THEN 1 END) as recent,+ COUNT(CASE WHEN comments.created_at > CURRENT_DATE - INTERVAL '30 days' THEN 1 END) as recent,COUNT(*) as allFROM commentsINNER JOIN posts@@ -141,7 +141,7 @@ var (agg_votes AS (SELECTpost_id,- COUNT(CASE WHEN post_votes.created_on > CURRENT_DATE - INTERVAL '30 days' THEN 1 END) as recent,+ COUNT(CASE WHEN post_votes.created_at > CURRENT_DATE - INTERVAL '30 days' THEN 1 END) as recent,COUNT(*) as allFROM post_votesINNER JOIN posts@@ -155,7 +155,7 @@ var (p.title,p.slug,p.description,- p.created_on,+ p.created_at,COALESCE(agg_s.all, 0) as votes,COALESCE(agg_c.all, 0) as comments,COALESCE(agg_s.recent, 0) AS recent_votes,@@ -328,8 +328,8 @@ func (s *PostStorage) GetCommentsByPost(post *models.Post) ([]*models.Comment, eerr := s.trx.Select(&comments,`SELECT c.id,c.content,- c.created_on,- c.edited_on,+ c.created_at,+ c.edited_at,u.id AS user_id,u.name AS user_name,u.email AS user_email,@@ -352,7 +352,7 @@ func (s *PostStorage) GetCommentsByPost(post *models.Post) ([]*models.Comment, eAND e.tenant_id = c.tenant_idWHERE p.id = $1AND p.tenant_id = $2- ORDER BY c.created_on ASC`, post.ID, s.tenant.ID)+ ORDER BY c.created_at ASC`, post.ID, s.tenant.ID)if err != nil {return nil, errors.Wrap(err, "failed get comments of post with id '%d'", post.ID)}@@ -383,7 +383,7 @@ func (s *PostStorage) Update(post *models.Post, title, description string) (*modfunc (s *PostStorage) Add(title, description string) (*models.Post, error) {var id interr := s.trx.Get(&id,- `INSERT INTO posts (title, slug, number, description, tenant_id, user_id, created_on, status)+ `INSERT INTO posts (title, slug, number, description, tenant_id, user_id, created_at, status)VALUES ($1, $2, (SELECT COALESCE(MAX(number), 0) + 1 FROM posts p WHERE p.tenant_id = $4), $3, $4, $5, $6, 0)RETURNING id`, title, slug.Make(title), description, s.tenant.ID, s.user.ID, time.Now())if err != nil {@@ -406,7 +406,7 @@ func (s *PostStorage) Add(title, description string) (*models.Post, error) {func (s *PostStorage) AddComment(post *models.Post, content string) (int, error) {var id intif err := s.trx.Get(&id,- "INSERT INTO comments (tenant_id, post_id, content, user_id, created_on) VALUES ($1, $2, $3, $4, $5) RETURNING id",+ "INSERT INTO comments (tenant_id, post_id, content, user_id, created_at) VALUES ($1, $2, $3, $4, $5) RETURNING id",s.tenant.ID, post.ID, content, s.user.ID, time.Now()); err != nil {return 0, errors.Wrap(err, "failed add new comment")}@@ -424,8 +424,8 @@ func (s *PostStorage) GetCommentByID(id int) (*models.Comment, error) {err := s.trx.Get(&comment,`SELECT c.id,c.content,- c.created_on,- c.edited_on,+ c.created_at,+ c.edited_at,u.id AS user_id,u.name AS user_name,u.email AS user_email,@@ -456,7 +456,7 @@ func (s *PostStorage) GetCommentByID(id int) (*models.Comment, error) {// UpdateComment with given ID and contentfunc (s *PostStorage) UpdateComment(id int, content string) error {_, err := s.trx.Execute(`- UPDATE comments SET content = $1, edited_on = $2, edited_by_id = $3+ UPDATE comments SET content = $1, edited_at = $2, edited_by_id = $3WHERE id = $4 AND tenant_id = $5`, content, time.Now(), s.user.ID, id, s.tenant.ID)if err != nil {return errors.Wrap(err, "failed update comment")@@ -471,7 +471,7 @@ func (s *PostStorage) AddVote(post *models.Post, user *models.User) error {}_, err := s.trx.Execute(- `INSERT INTO post_votes (tenant_id, user_id, post_id, created_on) VALUES ($1, $2, $3, $4) ON CONFLICT DO NOTHING`,+ `INSERT INTO post_votes (tenant_id, user_id, post_id, created_at) VALUES ($1, $2, $3, $4) ON CONFLICT DO NOTHING`,s.tenant.ID, user.ID, post.ID, time.Now())if err != nil {@@ -503,11 +503,11 @@ func (s *PostStorage) AddSubscriber(post *models.Post, user *models.User) errorfunc (s *PostStorage) internalAddSubscriber(post *models.Post, user *models.User, force bool) error {conflict := " DO NOTHING"if force {- conflict = "(user_id, post_id) DO UPDATE SET status = $5, updated_on = $4"+ conflict = "(user_id, post_id) DO UPDATE SET status = $5, updated_at = $4"}_, err := s.trx.Execute(fmt.Sprintf(`- INSERT INTO post_subscribers (tenant_id, user_id, post_id, created_on, updated_on, status)+ INSERT INTO post_subscribers (tenant_id, user_id, post_id, created_at, updated_at, status)VALUES ($1, $2, $3, $4, $4, $5) ON CONFLICT %s`, conflict),s.tenant.ID, user.ID, post.ID, time.Now(), models.SubscriberActive,)@@ -520,9 +520,9 @@ func (s *PostStorage) internalAddSubscriber(post *models.Post, user *models.User// RemoveSubscriber removes user from post list of subscribersfunc (s *PostStorage) RemoveSubscriber(post *models.Post, user *models.User) error {_, err := s.trx.Execute(`- INSERT INTO post_subscribers (tenant_id, user_id, post_id, created_on, updated_on, status)+ INSERT INTO post_subscribers (tenant_id, user_id, post_id, created_at, updated_at, status)VALUES ($1, $2, $3, $4, $4, 0) ON CONFLICT (user_id, post_id)- DO UPDATE SET status = 0, updated_on = $4`,+ DO UPDATE SET status = 0, updated_at = $4`,s.tenant.ID, user.ID, post.ID, time.Now(),)if err != nil {@@ -609,16 +609,16 @@ func (s *PostStorage) SetResponse(post *models.Post, text string, status int) erreturn errors.New("Use MarkAsDuplicate to change an post status to Duplicate")}- respondedOn := time.Now()+ respondedAt := time.Now()if post.Status == status && post.Response != nil {- respondedOn = post.Response.RespondedOn+ respondedAt = post.Response.RespondedAt}_, err := s.trx.Execute(`UPDATE postsSET response = $3, original_id = NULL, response_date = $4, response_user_id = $5, status = $6WHERE id = $1 and tenant_id = $2- `, post.ID, s.tenant.ID, text, respondedOn, s.user.ID, status)+ `, post.ID, s.tenant.ID, text, respondedAt, s.user.ID, status)if err != nil {return errors.Wrap(err, "failed to update post's response")}@@ -626,7 +626,7 @@ func (s *PostStorage) SetResponse(post *models.Post, text string, status int) erpost.Status = statuspost.Response = &models.PostResponse{Text: text,- RespondedOn: respondedOn,+ RespondedAt: respondedAt,User: s.user,}return nil@@ -634,9 +634,9 @@ func (s *PostStorage) SetResponse(post *models.Post, text string, status int) er// MarkAsDuplicate set post as a duplicate of another postfunc (s *PostStorage) MarkAsDuplicate(post *models.Post, original *models.Post) error {- respondedOn := time.Now()+ respondedAt := time.Now()if post.Status == models.PostDuplicate && post.Response != nil {- respondedOn = post.Response.RespondedOn+ respondedAt = post.Response.RespondedAt}var users []*dbUser@@ -655,14 +655,14 @@ func (s *PostStorage) MarkAsDuplicate(post *models.Post, original *models.Post)UPDATE postsSET response = '', original_id = $3, response_date = $4, response_user_id = $5, status = $6WHERE id = $1 and tenant_id = $2- `, post.ID, s.tenant.ID, original.ID, respondedOn, s.user.ID, models.PostDuplicate)+ `, post.ID, s.tenant.ID, original.ID, respondedAt, s.user.ID, models.PostDuplicate)if err != nil {return errors.Wrap(err, "failed to update post's response")}post.Status = models.PostDuplicatepost.Response = &models.PostResponse{- RespondedOn: respondedOn,+ RespondedAt: respondedAt,User: s.user,Original: &models.OriginalPost{Number: original.Number,diff --git a/app/storage/postgres/post_test.go b/app/storage/postgres/post_test.goindex e9b0d27c3..6eda44daf 100644--- a/app/storage/postgres/post_test.go+++ b/app/storage/postgres/post_test.go@@ -16,8 +16,8 @@ func TestPostStorage_GetAll(t *testing.T) {now := time.Now()- trx.Execute("INSERT INTO posts (title, slug, number, description, created_on, tenant_id, user_id, status) VALUES ('add twitter integration', 'add-twitter-integration', 1, 'Would be great to see it integrated with twitter', $1, 1, 1, 1)", now)- trx.Execute("INSERT INTO posts (title, slug, number, description, created_on, tenant_id, user_id, status) VALUES ('this is my post', 'this-is-my-post', 2, 'no description', $1, 1, 2, 2)", now)+ trx.Execute("INSERT INTO posts (title, slug, number, description, created_at, tenant_id, user_id, status) VALUES ('add twitter integration', 'add-twitter-integration', 1, 'Would be great to see it integrated with twitter', $1, 1, 1, 1)", now)+ trx.Execute("INSERT INTO posts (title, slug, number, description, created_at, tenant_id, user_id, status) VALUES ('this is my post', 'this-is-my-post', 2, 'no description', $1, 1, 2, 2)", now)posts.SetCurrentTenant(demoTenant)@@ -140,7 +140,7 @@ func TestPostStorage_AddGetUpdateComment(t *testing.T) {Expect(comment.ID).Equals(commentID)Expect(comment.Content).Equals("Comment #1")Expect(comment.User.ID).Equals(jonSnow.ID)- Expect(comment.EditedOn).IsNil()+ Expect(comment.EditedAt).IsNil()Expect(comment.EditedBy).IsNil()posts.SetCurrentUser(aryaStark)@@ -152,7 +152,7 @@ func TestPostStorage_AddGetUpdateComment(t *testing.T) {Expect(comment.ID).Equals(commentID)Expect(comment.Content).Equals("Comment #1 with edit")Expect(comment.User.ID).Equals(jonSnow.ID)- Expect(comment.EditedOn).IsNotNil()+ Expect(comment.EditedAt).IsNotNil()Expect(comment.EditedBy.ID).Equals(aryaStark.ID)}@@ -336,15 +336,15 @@ func TestPostStorage_SetResponse_ChangeText(t *testing.T) {post, _ := posts.Add("My new post", "with this description")posts.SetResponse(post, "We liked this post", models.PostStarted)post, _ = posts.GetByID(post.ID)- respondedOn := post.Response.RespondedOn+ respondedAt := post.Response.RespondedAtposts.SetResponse(post, "We liked this post and we'll work on it", models.PostStarted)post, _ = posts.GetByID(post.ID)- Expect(post.Response.RespondedOn).Equals(respondedOn)+ Expect(post.Response.RespondedAt).Equals(respondedAt)posts.SetResponse(post, "We finished it", models.PostCompleted)post, _ = posts.GetByID(post.ID)- Expect(post.Response.RespondedOn).TemporarilySimilar(respondedOn, time.Second)+ Expect(post.Response.RespondedAt).TemporarilySimilar(respondedAt, time.Second)}func TestPostStorage_SetResponse_AsDuplicate(t *testing.T) {diff --git a/app/storage/postgres/tag.go b/app/storage/postgres/tag.goindex 3b3a3d343..0e9762d40 100644--- a/app/storage/postgres/tag.go+++ b/app/storage/postgres/tag.go@@ -58,7 +58,7 @@ func (s *TagStorage) Add(name, color string, isPublic bool) (*models.Tag, error)var id interr := s.trx.Get(&id, `- INSERT INTO tags (name, slug, color, is_public, created_on, tenant_id)+ INSERT INTO tags (name, slug, color, is_public, created_at, tenant_id)VALUES ($1, $2, $3, $4, $5, $6) RETURNING id`, name, tagSlug, color, isPublic, time.Now(), s.tenant.ID)if err != nil {@@ -119,7 +119,7 @@ func (s *TagStorage) AssignTag(tag *models.Tag, post *models.Post) error {}_, err = s.trx.Execute(- `INSERT INTO post_tags (tag_id, post_id, created_on, created_by_id, tenant_id) VALUES ($1, $2, $3, $4, $5)`,+ `INSERT INTO post_tags (tag_id, post_id, created_at, created_by_id, tenant_id) VALUES ($1, $2, $3, $4, $5)`,tag.ID, post.ID, time.Now(), s.user.ID, s.tenant.ID,)diff --git a/app/storage/postgres/tenant.go b/app/storage/postgres/tenant.goindex 34422d73b..599cfeb35 100644--- a/app/storage/postgres/tenant.go+++ b/app/storage/postgres/tenant.go@@ -56,9 +56,9 @@ type dbEmailVerification struct {Key string `db:"key"`Kind models.EmailVerificationKind `db:"kind"`UserID dbx.NullInt `db:"user_id"`- CreatedOn time.Time `db:"created_on"`- ExpiresOn time.Time `db:"expires_on"`- VerifiedOn dbx.NullTime `db:"verified_on"`+ CreatedAt time.Time `db:"created_at"`+ ExpiresAt time.Time `db:"expires_at"`+ VerifiedAt dbx.NullTime `db:"verified_at"`}func (t *dbEmailVerification) toModel() *models.EmailVerification {@@ -67,13 +67,13 @@ func (t *dbEmailVerification) toModel() *models.EmailVerification {Email: t.Email,Key: t.Key,Kind: t.Kind,- CreatedOn: t.CreatedOn,- ExpiresOn: t.ExpiresOn,- VerifiedOn: nil,+ CreatedAt: t.CreatedAt,+ ExpiresAt: t.ExpiresAt,+ VerifiedAt: nil,}- if t.VerifiedOn.Valid {- model.VerifiedOn = &t.VerifiedOn.Time+ if t.VerifiedAt.Valid {+ model.VerifiedAt = &t.VerifiedAt.Time}if t.UserID.Valid {@@ -145,7 +145,7 @@ func (s *TenantStorage) SetCurrentUser(user *models.User) {func (s *TenantStorage) Add(name string, subdomain string, status int) (*models.Tenant, error) {var id interr := s.trx.Get(&id,- `INSERT INTO tenants (name, subdomain, created_on, cname, invitation, welcome_message, status, is_private, custom_css)+ `INSERT INTO tenants (name, subdomain, created_at, cname, invitation, welcome_message, status, is_private, custom_css)VALUES ($1, $2, $3, '', '', '', $4, false, '')RETURNING id`, name, subdomain, time.Now(), status)if err != nil {@@ -223,7 +223,7 @@ func (s *TenantStorage) UpdateSettings(settings *models.UpdateTenantSettings) erfunc (s *TenantStorage) SaveNewUpload(content []byte) (int, error) {var newID interr := s.trx.Get(&newID, `- INSERT INTO uploads (tenant_id, size, content_type, file, created_on)+ INSERT INTO uploads (tenant_id, size, content_type, file, created_at)VALUES ($1, $2, $3, $4, $5) RETURNING id`, s.current.ID, len(content), http.DetectContentType(content), content, time.Now(),)@@ -289,7 +289,7 @@ func (s *TenantStorage) SaveVerificationKey(key string, duration time.Duration,userID = request.GetUser().ID}- query := "INSERT INTO email_verifications (tenant_id, email, created_on, expires_on, key, name, kind, user_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)"+ query := "INSERT INTO email_verifications (tenant_id, email, created_at, expires_at, key, name, kind, user_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)"_, err := s.trx.Execute(query, s.current.ID, request.GetEmail(), time.Now(), time.Now().Add(duration), key, request.GetName(), request.GetKind(), userID)if err != nil {return errors.Wrap(err, "failed to save verification key for kind '%d'", request.GetKind())@@ -301,7 +301,7 @@ func (s *TenantStorage) SaveVerificationKey(key string, duration time.Duration,func (s *TenantStorage) FindVerificationByKey(kind models.EmailVerificationKind, key string) (*models.EmailVerification, error) {verification := dbEmailVerification{}- query := "SELECT id, email, name, key, created_on, verified_on, expires_on, kind, user_id FROM email_verifications WHERE key = $1 AND kind = $2 LIMIT 1"+ query := "SELECT id, email, name, key, created_at, verified_at, expires_at, kind, user_id FROM email_verifications WHERE key = $1 AND kind = $2 LIMIT 1"err := s.trx.Get(&verification, query, key, kind)if err != nil {return nil, errors.Wrap(err, "failed to get email verification by its key")@@ -312,7 +312,7 @@ func (s *TenantStorage) FindVerificationByKey(kind models.EmailVerificationKind,// SetKeyAsVerified so that it cannot be used anymorefunc (s *TenantStorage) SetKeyAsVerified(key string) error {- query := "UPDATE email_verifications SET verified_on = $1 WHERE tenant_id = $2 AND key = $3"+ query := "UPDATE email_verifications SET verified_at = $1 WHERE tenant_id = $2 AND key = $3"_, err := s.trx.Execute(query, time.Now(), s.current.ID, key)if err != nil {return errors.Wrap(err, "failed to update verified date of email verification request")diff --git a/app/storage/postgres/tenant_test.go b/app/storage/postgres/tenant_test.goindex 90d850607..db3e9e644 100644--- a/app/storage/postgres/tenant_test.go+++ b/app/storage/postgres/tenant_test.go@@ -297,29 +297,29 @@ func TestTenantStorage_SaveFindSet_VerificationKey(t *testing.T) {//Find and check valuesresult, err := tenants.FindVerificationByKey(models.EmailVerificationKindSignUp, "s3cr3tk3y")Expect(err).IsNil()- Expect(result.CreatedOn).TemporarilySimilar(time.Now(), 1*time.Second)- Expect(result.VerifiedOn).IsNil()+ Expect(result.CreatedAt).TemporarilySimilar(time.Now(), 1*time.Second)+ Expect(result.VerifiedAt).IsNil()Expect(result.Email).Equals("[email protected]")Expect(result.Name).Equals("Jon Snow")Expect(result.Kind).Equals(models.EmailVerificationKindSignUp)Expect(result.Key).Equals("s3cr3tk3y")Expect(result.UserID).Equals(0)- Expect(result.ExpiresOn).TemporarilySimilar(result.CreatedOn.Add(15*time.Minute), 1*time.Second)+ Expect(result.ExpiresAt).TemporarilySimilar(result.CreatedAt.Add(15*time.Minute), 1*time.Second)//Set as verified check valueserr = tenants.SetKeyAsVerified("s3cr3tk3y")Expect(err).IsNil()- //Find and check that VerifiedOn is now set+ //Find and check that VerifiedAt is now setresult, err = tenants.FindVerificationByKey(models.EmailVerificationKindSignUp, "s3cr3tk3y")Expect(err).IsNil()- Expect(time.Now().After(result.CreatedOn)).IsTrue()- Expect(result.VerifiedOn.After(result.CreatedOn)).IsTrue()+ Expect(time.Now().After(result.CreatedAt)).IsTrue()+ Expect(result.VerifiedAt.After(result.CreatedAt)).IsTrue()Expect(result.Email).Equals("[email protected]")Expect(result.Name).Equals("Jon Snow")Expect(result.Key).Equals("s3cr3tk3y")Expect(result.UserID).Equals(0)- Expect(result.ExpiresOn).TemporarilySimilar(result.CreatedOn.Add(15*time.Minute), 1*time.Second)+ Expect(result.ExpiresAt).TemporarilySimilar(result.CreatedAt.Add(15*time.Minute), 1*time.Second)//Wrong kind should not find itresult, err = tenants.FindVerificationByKey(models.EmailVerificationKindSignIn, "s3cr3tk3y")@@ -345,14 +345,14 @@ func TestTenantStorage_SaveFindSet_ChangeEmailVerificationKey(t *testing.T) {//Find and check valuesresult, err := tenants.FindVerificationByKey(models.EmailVerificationKindChangeEmail, "th3-s3cr3t")Expect(err).IsNil()- Expect(result.CreatedOn).TemporarilySimilar(time.Now(), 1*time.Second)- Expect(result.VerifiedOn).IsNil()+ Expect(result.CreatedAt).TemporarilySimilar(time.Now(), 1*time.Second)+ Expect(result.VerifiedAt).IsNil()Expect(result.Email).Equals("[email protected]")Expect(result.Name).Equals("")Expect(result.Kind).Equals(models.EmailVerificationKindChangeEmail)Expect(result.Key).Equals("th3-s3cr3t")Expect(result.UserID).Equals(jonSnow.ID)- Expect(result.ExpiresOn).TemporarilySimilar(result.CreatedOn.Add(15*time.Minute), 1*time.Second)+ Expect(result.ExpiresAt).TemporarilySimilar(result.CreatedAt.Add(15*time.Minute), 1*time.Second)}func TestTenantStorage_FindUnknownVerificationKey(t *testing.T) {diff --git a/app/storage/postgres/user.go b/app/storage/postgres/user.goindex 53d5d3ee2..7a70b0dc8 100644--- a/app/storage/postgres/user.go+++ b/app/storage/postgres/user.go@@ -122,13 +122,13 @@ func (s *UserStorage) Register(user *models.User) error {user.Status = models.UserActiveuser.Email = strings.TrimSpace(user.Email)if err := s.trx.Get(&user.ID,- "INSERT INTO users (name, email, created_on, tenant_id, role, status) VALUES ($1, $2, $3, $4, $5, $6) RETURNING id",+ "INSERT INTO users (name, email, created_at, tenant_id, role, status) VALUES ($1, $2, $3, $4, $5, $6) RETURNING id",user.Name, user.Email, now, s.tenant.ID, user.Role, models.UserActive); err != nil {return errors.Wrap(err, "failed to register new user")}for _, provider := range user.Providers {- if _, err := s.trx.Execute("INSERT INTO user_providers (tenant_id, user_id, provider, provider_uid, created_on) VALUES ($1, $2, $3, $4, $5)", s.tenant.ID, user.ID, provider.Name, provider.UID, now); err != nil {+ if _, err := s.trx.Execute("INSERT INTO user_providers (tenant_id, user_id, provider, provider_uid, created_at) VALUES ($1, $2, $3, $4, $5)", s.tenant.ID, user.ID, provider.Name, provider.UID, now); err != nil {return errors.Wrap(err, "failed to add provider to new user")}}@@ -138,7 +138,7 @@ func (s *UserStorage) Register(user *models.User) error {// RegisterProvider adds given provider to userIDfunc (s *UserStorage) RegisterProvider(userID int, provider *models.UserProvider) error {- cmd := "INSERT INTO user_providers (tenant_id, user_id, provider, provider_uid, created_on) VALUES ($1, $2, $3, $4, $5)"+ cmd := "INSERT INTO user_providers (tenant_id, user_id, provider, provider_uid, created_at) VALUES ($1, $2, $3, $4, $5)"_, err := s.trx.Execute(cmd, s.tenant.ID, userID, provider.Name, provider.UID, time.Now())if err != nil {return errors.Wrap(err, "failed to add provider '%s' to user with id '%d'", provider.Name, userID)diff --git a/app/storage/postgres/user_test.go b/app/storage/postgres/user_test.goindex 5cb154e71..a65a787c1 100644--- a/app/storage/postgres/user_test.go+++ b/app/storage/postgres/user_test.go@@ -143,7 +143,7 @@ func TestUserStorage_Register_MultipleProviders(t *testing.T) {var tenantID inttrx.Get(&tenantID, `- INSERT INTO tenants (name, subdomain, created_on, status, is_private, custom_css)+ INSERT INTO tenants (name, subdomain, created_at, status, is_private, custom_css)VALUES ('My Domain Inc.','mydomain', now(), 1, false, '')RETURNING id`)diff --git a/app/tasks/tasks_test.go b/app/tasks/tasks_test.goindex 6d53b0c79..a21902a4b 100644--- a/app/tasks/tasks_test.go+++ b/app/tasks/tasks_test.go@@ -152,7 +152,7 @@ func TestNotifyAboutNewPostTask(t *testing.T) {Expect(err).IsNil()Expect(notifications).HasLen(1)Expect(notifications[0].ID).Equals(1)- Expect(notifications[0].CreatedOn).TemporarilySimilar(time.Now(), 5*time.Second)+ Expect(notifications[0].CreatedAt).TemporarilySimilar(time.Now(), 5*time.Second)Expect(notifications[0].Link).Equals("/posts/1/add-support-for-typescript")Expect(notifications[0].Read).IsFalse()Expect(notifications[0].Title).Equals("New post: **Add support for TypeScript**")@@ -205,7 +205,7 @@ func TestNotifyAboutNewCommentTask(t *testing.T) {Expect(err).IsNil()Expect(notifications).HasLen(1)Expect(notifications[0].ID).Equals(1)- Expect(notifications[0].CreatedOn).TemporarilySimilar(time.Now(), 5*time.Second)+ Expect(notifications[0].CreatedAt).TemporarilySimilar(time.Now(), 5*time.Second)Expect(notifications[0].Link).Equals("/posts/1/add-support-for-typescript")Expect(notifications[0].Read).IsFalse()Expect(notifications[0].Title).Equals("**Arya Stark** left a comment on **Add support for TypeScript**")@@ -256,7 +256,7 @@ func TestNotifyAboutStatusChangeTask(t *testing.T) {Expect(err).IsNil()Expect(notifications).HasLen(1)Expect(notifications[0].ID).Equals(1)- Expect(notifications[0].CreatedOn).TemporarilySimilar(time.Now(), 5*time.Second)+ Expect(notifications[0].CreatedAt).TemporarilySimilar(time.Now(), 5*time.Second)Expect(notifications[0].Link).Equals("/posts/1/add-support-for-typescript")Expect(notifications[0].Read).IsFalse()Expect(notifications[0].Title).Equals("**Jon Snow** changed status of **Add support for TypeScript** to **Planned**")@@ -308,7 +308,7 @@ func TestNotifyAboutStatusChangeTask_Duplicate(t *testing.T) {Expect(err).IsNil()Expect(notifications).HasLen(1)Expect(notifications[0].ID).Equals(1)- Expect(notifications[0].CreatedOn).TemporarilySimilar(time.Now(), 5*time.Second)+ Expect(notifications[0].CreatedAt).TemporarilySimilar(time.Now(), 5*time.Second)Expect(notifications[0].Link).Equals("/posts/2/i-need-typescript")Expect(notifications[0].Read).IsFalse()Expect(notifications[0].Title).Equals("**Jon Snow** changed status of **I need TypeScript** to **Duplicate**")diff --git a/migrations/201809262108_rename_datetime_fields.sql b/migrations/201809262108_rename_datetime_fields.sqlnew file mode 100644index 000000000..8f8f29d0d--- /dev/null+++ b/migrations/201809262108_rename_datetime_fields.sql@@ -0,0 +1,19 @@+ALTER TABLE logs RENAME COLUMN created_on TO created_at;+ALTER TABLE post_subscribers RENAME COLUMN created_on TO created_at;+ALTER TABLE post_subscribers RENAME COLUMN updated_on TO updated_at;+ALTER TABLE user_providers RENAME COLUMN created_on TO created_at;+ALTER TABLE post_votes RENAME COLUMN created_on TO created_at;+ALTER TABLE oauth_providers RENAME COLUMN created_on TO created_at;+ALTER TABLE posts RENAME COLUMN created_on TO created_at;+ALTER TABLE uploads RENAME COLUMN created_on TO created_at;+ALTER TABLE tenants RENAME COLUMN created_on TO created_at;+ALTER TABLE post_tags RENAME COLUMN created_on TO created_at;+ALTER TABLE tags RENAME COLUMN created_on TO created_at;+ALTER TABLE notifications RENAME COLUMN created_on TO created_at;+ALTER TABLE notifications RENAME COLUMN updated_on TO updated_at;+ALTER TABLE users RENAME COLUMN created_on TO created_at;+ALTER TABLE comments RENAME COLUMN created_on TO created_at;+ALTER TABLE comments RENAME COLUMN edited_on TO edited_at;+ALTER TABLE email_verifications RENAME COLUMN created_on TO created_at;+ALTER TABLE email_verifications RENAME COLUMN verified_on TO verified_at;+ALTER TABLE email_verifications RENAME COLUMN expires_on TO expires_at;diff --git a/public/components/VoteCounter.spec.tsx b/public/components/VoteCounter.spec.tsxindex 3f3e5bbde..73316d65e 100644--- a/public/components/VoteCounter.spec.tsx+++ b/public/components/VoteCounter.spec.tsx@@ -13,7 +13,7 @@ beforeEach(() => {slug: "add-typescript",title: "Add TypeScript",description: "",- createdOn: "",+ createdAt: "",status: PostStatus.Started.value,user: {id: 5,diff --git a/public/models/notification.ts b/public/models/notification.tsindex bcdca5124..00802411b 100644--- a/public/models/notification.ts+++ b/public/models/notification.ts@@ -3,5 +3,5 @@ export interface Notification {title: string;link: string;read: boolean;- createdOn: string;+ createdAt: string;}diff --git a/public/models/post.ts b/public/models/post.tsindex e2c0c25ff..1d16211e2 100644--- a/public/models/post.ts+++ b/public/models/post.ts@@ -6,7 +6,7 @@ export interface Post {slug: string;title: string;description: string;- createdOn: string;+ createdAt: string;status: number;user: User;hasVoted: boolean;@@ -56,7 +56,7 @@ export class PostStatus {export interface PostResponse {user: User;text: string;- respondedOn: Date;+ respondedAt: Date;original?: {number: number;title: string;@@ -68,9 +68,9 @@ export interface PostResponse {export interface Comment {id: number;content: string;- createdOn: string;+ createdAt: string;user: User;- editedOn?: string;+ editedAt?: string;editedBy?: User;}diff --git a/public/pages/MyNotifications/MyNotifications.page.tsx b/public/pages/MyNotifications/MyNotifications.page.tsxindex 29cebdf45..42b491ea3 100644--- a/public/pages/MyNotifications/MyNotifications.page.tsx+++ b/public/pages/MyNotifications/MyNotifications.page.tsx@@ -40,7 +40,7 @@ export class MyNotificationsPage extends React.Component<MyNotificationsPageProp<a href={`/notifications/${n.id}`}><MultiLineText text={n.title} style="simple" /><span className="info">- <Moment date={n.createdOn} />+ <Moment date={n.createdAt} /></span></a></ListItem>diff --git a/public/pages/ShowPost/ShowPost.page.tsx b/public/pages/ShowPost/ShowPost.page.tsxindex 5685e4e62..dacfb07ce 100644--- a/public/pages/ShowPost/ShowPost.page.tsx+++ b/public/pages/ShowPost/ShowPost.page.tsx@@ -98,7 +98,7 @@ export class ShowPostPage extends React.Component<ShowPostPageProps, ShowPostPag)}<span className="info">- Shared <Moment date={this.props.post.createdOn} /> by <Gravatar user={this.props.post.user} />{" "}+ Shared <Moment date={this.props.post.createdAt} /> by <Gravatar user={this.props.post.user} />{" "}<UserName user={this.props.post.user} /></span></div>diff --git a/public/pages/ShowPost/components/ShowComment.tsx b/public/pages/ShowPost/components/ShowComment.tsxindex 5ad1be122..542feaa4d 100644--- a/public/pages/ShowPost/components/ShowComment.tsx+++ b/public/pages/ShowPost/components/ShowComment.tsx@@ -48,7 +48,7 @@ export class ShowComment extends React.Component<ShowCommentProps, ShowCommentStconst response = await actions.updateComment(this.props.post.number, this.state.comment.id, this.state.newContent);if (response.ok) {this.state.comment.content = this.state.newContent;- this.state.comment.editedOn = new Date().toISOString();+ this.state.comment.editedAt = new Date().toISOString();this.state.comment.editedBy = Fider.session.user;this.setState({comment: this.state.comment@@ -66,11 +66,11 @@ export class ShowComment extends React.Component<ShowCommentProps, ShowCommentStpublic render() {const c = this.state.comment;- const edittedMetadata = !!c.editedOn &&+ const edittedMetadata = !!c.editedAt &&!!c.editedBy && (<div className="c-comment-metadata">·{" "}- <span title={`This comment has been edited by ${c.editedBy!.name} on ${formatDate(c.editedOn)}`}>edited</span>+ <span title={`This comment has been edited by ${c.editedBy!.name} on ${formatDate(c.editedAt)}`}>edited</span></div>);@@ -80,7 +80,7 @@ export class ShowComment extends React.Component<ShowCommentProps, ShowCommentSt<div className="c-comment-content"><UserName user={c.user} /><div className="c-comment-metadata">- · <Moment date={c.createdOn} />+ · <Moment date={c.createdAt} /></div>{edittedMetadata}{!this.state.isEditting &&