summaryrefslogtreecommitdiff
path: root/internal/db/bundb/poll.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2024-02-07 14:43:27 +0000
committerLibravatar GitHub <noreply@github.com>2024-02-07 14:43:27 +0000
commit6738fd5bb0193daf3e2b524105ff690e8bfc32f4 (patch)
tree1c9b84846e21c737746f2a528170ad1d4bfb0a1c /internal/db/bundb/poll.go
parent[bugfix] Ensure activities sender always = activities actor (#2608) (diff)
downloadgotosocial-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/poll.go')
-rw-r--r--internal/db/bundb/poll.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/internal/db/bundb/poll.go b/internal/db/bundb/poll.go
index 0dfb15621..37a1f26ab 100644
--- a/internal/db/bundb/poll.go
+++ b/internal/db/bundb/poll.go
@@ -34,7 +34,7 @@ import (
)
type pollDB struct {
- db *DB
+ db *bun.DB
state *state.State
}
@@ -154,7 +154,7 @@ func (p *pollDB) UpdatePoll(ctx context.Context, poll *gtsmodel.Poll, cols ...st
poll.CheckVotes()
return p.state.Caches.GTS.Poll.Store(poll, func() error {
- return p.db.RunInTx(ctx, func(tx Tx) error {
+ return p.db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error {
// Update the status' "updated_at" field.
if _, err := tx.NewUpdate().
Table("statuses").
@@ -362,7 +362,7 @@ func (p *pollDB) PopulatePollVote(ctx context.Context, vote *gtsmodel.PollVote)
func (p *pollDB) PutPollVote(ctx context.Context, vote *gtsmodel.PollVote) error {
return p.state.Caches.GTS.PollVote.Store(vote, func() error {
- return p.db.RunInTx(ctx, func(tx Tx) error {
+ return p.db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error {
// Try insert vote into database.
if _, err := tx.NewInsert().
Model(vote).
@@ -398,7 +398,7 @@ func (p *pollDB) PutPollVote(ctx context.Context, vote *gtsmodel.PollVote) error
}
func (p *pollDB) DeletePollVotes(ctx context.Context, pollID string) error {
- err := p.db.RunInTx(ctx, func(tx Tx) error {
+ err := p.db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error {
// Delete all votes in poll.
res, err := tx.NewDelete().
Table("poll_votes").
@@ -469,7 +469,7 @@ func (p *pollDB) DeletePollVotes(ctx context.Context, pollID string) error {
}
func (p *pollDB) DeletePollVoteBy(ctx context.Context, pollID string, accountID string) error {
- err := p.db.RunInTx(ctx, func(tx Tx) error {
+ err := p.db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error {
// Slice should only ever be of length
// 0 or 1; it's a slice of slices only
// because we can't LIMIT deletes to 1.
@@ -569,7 +569,7 @@ func (p *pollDB) DeletePollVotesByAccountID(ctx context.Context, accountID strin
}
// newSelectPollVotes returns a new select query for all rows in the poll_votes table with poll_id = pollID.
-func newSelectPollVotes(db *DB, pollID string) *bun.SelectQuery {
+func newSelectPollVotes(db *bun.DB, pollID string) *bun.SelectQuery {
return db.NewSelect().
TableExpr("?", bun.Ident("poll_votes")).
ColumnExpr("?", bun.Ident("id")).