From c013892ca22fe6bface8dc580571b2f0527cd1db Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Wed, 8 Jan 2025 10:29:23 +0000 Subject: [chore] replace statuses.updated_at column with statuses.edited_at (#3636) * update statuses table to replace updated_at column with edited_at * code comment * better code comments, fix setting of status + edit + mention + poll database times * fix log to logf call * fix status.EditIDs not being carried over in dereferencer.encrichStatus() * move status.EditID setting into handleStatusEdit() --- internal/gtsmodel/status.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'internal/gtsmodel') diff --git a/internal/gtsmodel/status.go b/internal/gtsmodel/status.go index 3a348bba4..d28898ed1 100644 --- a/internal/gtsmodel/status.go +++ b/internal/gtsmodel/status.go @@ -28,7 +28,7 @@ import ( type Status struct { ID string `bun:"type:CHAR(26),pk,nullzero,notnull,unique"` // id of this item in the database CreatedAt time.Time `bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created - UpdatedAt time.Time `bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated + EditedAt time.Time `bun:"type:timestamptz,nullzero"` // when this status was last edited (if set) FetchedAt time.Time `bun:"type:timestamptz,nullzero"` // when was item (remote) last fetched. PinnedAt time.Time `bun:"type:timestamptz,nullzero"` // Status was pinned by owning account at this time. URI string `bun:",unique,nullzero,notnull"` // activitypub URI of this status @@ -299,6 +299,15 @@ func (s *Status) AllAttachmentIDs() []string { return xslices.Deduplicate(attachmentIDs) } +// UpdatedAt returns latest time this status +// was updated, either EditedAt or CreatedAt. +func (s *Status) UpdatedAt() time.Time { + if s.EditedAt.IsZero() { + return s.CreatedAt + } + return s.EditedAt +} + // StatusToTag is an intermediate struct to facilitate the many2many relationship between a status and one or more tags. type StatusToTag struct { StatusID string `bun:"type:CHAR(26),unique:statustag,nullzero,notnull"` -- cgit v1.3