summaryrefslogtreecommitdiff
path: root/internal/db/bundb/poll.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2024-04-02 11:03:40 +0100
committerLibravatar GitHub <noreply@github.com>2024-04-02 12:03:40 +0200
commitadf345f1ec0cb76a0df94a4505143d891659cba9 (patch)
treee0cca289c0a50f30191d4b65a2c336704570e470 /internal/db/bundb/poll.go
parent[feature] Option to hide followers/following (#2788) (diff)
downloadgotosocial-adf345f1ec0cb76a0df94a4505143d891659cba9.tar.xz
[chore] bump go structr cache version -> v0.6.0 (#2773)
* update go-structr library -> v0.6.0, add necessary wrapping types + code changes to support these changes * update readme with go-structr package changes * improved wrapping of the SliceCache type * add code comments for the cache wrapper types * remove test.out :innocent: --------- Co-authored-by: tobi <31960611+tsmethurst@users.noreply.github.com>
Diffstat (limited to 'internal/db/bundb/poll.go')
-rw-r--r--internal/db/bundb/poll.go19
1 files changed, 3 insertions, 16 deletions
diff --git a/internal/db/bundb/poll.go b/internal/db/bundb/poll.go
index 37a1f26ab..33b621805 100644
--- a/internal/db/bundb/poll.go
+++ b/internal/db/bundb/poll.go
@@ -270,23 +270,10 @@ func (p *pollDB) GetPollVotes(ctx context.Context, pollID string) ([]*gtsmodel.P
return nil, err
}
- // Preallocate at-worst possible length.
- uncached := make([]string, 0, len(voteIDs))
-
// Load all votes from IDs via cache loader callbacks.
- votes, err := p.state.Caches.GTS.PollVote.Load("ID",
-
- // Load cached + check for uncached.
- func(load func(keyParts ...any) bool) {
- for _, id := range voteIDs {
- if !load(id) {
- uncached = append(uncached, id)
- }
- }
- },
-
- // Uncached poll vote loader function.
- func() ([]*gtsmodel.PollVote, error) {
+ votes, err := p.state.Caches.GTS.PollVote.LoadIDs("ID",
+ voteIDs,
+ func(uncached []string) ([]*gtsmodel.PollVote, error) {
// Preallocate expected length of uncached votes.
votes := make([]*gtsmodel.PollVote, 0, len(uncached))