diff options
author | 2024-02-07 14:43:27 +0000 | |
---|---|---|
committer | 2024-02-07 14:43:27 +0000 | |
commit | 6738fd5bb0193daf3e2b524105ff690e8bfc32f4 (patch) | |
tree | 1c9b84846e21c737746f2a528170ad1d4bfb0a1c /internal/db/bundb/status.go | |
parent | [bugfix] Ensure activities sender always = activities actor (#2608) (diff) | |
download | gotosocial-6738fd5bb0193daf3e2b524105ff690e8bfc32f4.tar.xz |
[feature/performance] sqlite pragma optimize on close (#2596)
* wrap database drivers in order to handle error processing, hooks, etc
* remove dead code
* add code comment, remove unused blank imports
Diffstat (limited to 'internal/db/bundb/status.go')
-rw-r--r-- | internal/db/bundb/status.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/internal/db/bundb/status.go b/internal/db/bundb/status.go index 07a09050a..6d1788b5d 100644 --- a/internal/db/bundb/status.go +++ b/internal/db/bundb/status.go @@ -34,7 +34,7 @@ import ( ) type statusDB struct { - db *DB + db *bun.DB state *state.State } @@ -330,7 +330,7 @@ func (s *statusDB) PutStatus(ctx context.Context, status *gtsmodel.Status) error // It is safe to run this database transaction within cache.Store // as the cache does not attempt a mutex lock until AFTER hook. // - return s.db.RunInTx(ctx, func(tx Tx) error { + return s.db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error { // create links between this status and any emojis it uses for _, i := range status.EmojiIDs { if _, err := tx. @@ -414,7 +414,7 @@ func (s *statusDB) UpdateStatus(ctx context.Context, status *gtsmodel.Status, co // It is safe to run this database transaction within cache.Store // as the cache does not attempt a mutex lock until AFTER hook. // - return s.db.RunInTx(ctx, func(tx Tx) error { + return s.db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error { // create links between this status and any emojis it uses for _, i := range status.EmojiIDs { if _, err := tx. @@ -509,7 +509,7 @@ func (s *statusDB) DeleteStatusByID(ctx context.Context, id string) error { // On return ensure status invalidated from cache. defer s.state.Caches.GTS.Status.Invalidate("ID", id) - return s.db.RunInTx(ctx, func(tx Tx) error { + return s.db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error { // delete links between this status and any emojis it uses if _, err := tx. NewDelete(). @@ -697,6 +697,5 @@ func (s *statusDB) IsStatusBookmarkedBy(ctx context.Context, status *gtsmodel.St TableExpr("? AS ?", bun.Ident("status_bookmarks"), bun.Ident("status_bookmark")). Where("? = ?", bun.Ident("status_bookmark.status_id"), status.ID). Where("? = ?", bun.Ident("status_bookmark.account_id"), accountID) - - return s.db.Exists(ctx, q) + return exists(ctx, q) } |