[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()
This commit is contained in:
kim 2025-01-08 10:29:23 +00:00 committed by GitHub
commit c013892ca2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 417 additions and 118 deletions

View file

@ -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"`