diff options
author | 2022-11-18 17:23:14 +0100 | |
---|---|---|
committer | 2022-11-18 17:23:14 +0100 | |
commit | d98a48b446edb5bf2c3b79bdfd382d505a08a6fc (patch) | |
tree | 1dd1639f63fa25f561d2050af1baab1d3fb7ee28 /internal/gtsmodel/notification.go | |
parent | [docs] Add AUR Reference (#1054) (diff) | |
download | gotosocial-d98a48b446edb5bf2c3b79bdfd382d505a08a6fc.tar.xz |
[performance] don't use relations to select notification structs, use caches instead (#1072)
Diffstat (limited to 'internal/gtsmodel/notification.go')
-rw-r--r-- | internal/gtsmodel/notification.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/internal/gtsmodel/notification.go b/internal/gtsmodel/notification.go index d05898615..11792cca5 100644 --- a/internal/gtsmodel/notification.go +++ b/internal/gtsmodel/notification.go @@ -24,14 +24,14 @@ import "time" type Notification struct { ID string `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"` // id of this item in the database CreatedAt time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created - UpdatedAt time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated // when was item created + UpdatedAt time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated NotificationType NotificationType `validate:"oneof=follow follow_request mention reblog favourite poll status" bun:",nullzero,notnull"` // Type of this notification - TargetAccountID string `validate:"ulid" bun:"type:CHAR(26),nullzero,notnull"` // Which account does this notification target (ie., who will receive the notification?) - TargetAccount *Account `validate:"-" bun:"rel:belongs-to"` // Which account performed the action that created this notification? + TargetAccountID string `validate:"ulid" bun:"type:CHAR(26),nullzero,notnull"` // ID of the account targeted by the notification (ie., who will receive the notification?) + TargetAccount *Account `validate:"-" bun:"-"` // Account corresponding to TargetAccountID. Can be nil, always check first + select using ID if necessary. OriginAccountID string `validate:"ulid" bun:"type:CHAR(26),nullzero,notnull"` // ID of the account that performed the action that created the notification. - OriginAccount *Account `validate:"-" bun:"rel:belongs-to"` // Account corresponding to originAccountID + OriginAccount *Account `validate:"-" bun:"-"` // Account corresponding to OriginAccountID. Can be nil, always check first + select using ID if necessary. StatusID string `validate:"required_if=NotificationType mention,required_if=NotificationType reblog,required_if=NotificationType favourite,required_if=NotificationType status,omitempty,ulid" bun:"type:CHAR(26),nullzero"` // If the notification pertains to a status, what is the database ID of that status? - Status *Status `validate:"-" bun:"rel:belongs-to"` // Status corresponding to statusID + Status *Status `validate:"-" bun:"-"` // Status corresponding to StatusID. Can be nil, always check first + select using ID if necessary. Read *bool `validate:"-" bun:",nullzero,notnull,default:false"` // Notification has been seen/read } |