From faed35c9388bc28ea0fdfe3aae3b489ca952c006 Mon Sep 17 00:00:00 2001 From: kim Date: Sat, 31 May 2025 17:30:57 +0200 Subject: [performance] cache mute check results (#4202) This separates our the user mute handling from the typeconverter code, and creates a new "mutes" filter type (in a similar vein to the visibility filter) subpkg with its own result cache. This is a heavy mix of both chore given that mute calculation shouldn't have been handled in the conversion to frontend API types, and a performance bonus since we don't need to load and calculate so many things each time, just the single result each time with all necessary invalidation handled by database cache hooks. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4202 Co-authored-by: kim Co-committed-by: kim --- internal/processing/status/context.go | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) (limited to 'internal/processing/status/context.go') diff --git a/internal/processing/status/context.go b/internal/processing/status/context.go index c18a4f7bd..6f3e7a4fd 100644 --- a/internal/processing/status/context.go +++ b/internal/processing/status/context.go @@ -25,7 +25,6 @@ import ( apimodel "code.superseriousbusiness.org/gotosocial/internal/api/model" statusfilter "code.superseriousbusiness.org/gotosocial/internal/filter/status" - "code.superseriousbusiness.org/gotosocial/internal/gtscontext" "code.superseriousbusiness.org/gotosocial/internal/gtserror" "code.superseriousbusiness.org/gotosocial/internal/gtsmodel" ) @@ -291,26 +290,8 @@ func (p *Processor) ContextGet( return nil, gtserror.NewErrorInternalError(err) } - // Retrieve mutes as they affect - // what should be shown to requester. - mutes, err := p.state.DB.GetAccountMutes( - // No need to populate mutes, - // IDs are enough here. - gtscontext.SetBarebones(ctx), - requester.ID, - nil, // No paging - get all. - ) - if err != nil { - err = gtserror.Newf( - "couldn't retrieve mutes for account %s: %w", - requester.ID, err, - ) - return nil, gtserror.NewErrorInternalError(err) - } - // Retrieve the full thread context. - threadContext, errWithCode := p.contextGet( - ctx, + threadContext, errWithCode := p.contextGet(ctx, requester, targetStatusID, ) @@ -326,7 +307,6 @@ func (p *Processor) ContextGet( threadContext.ancestors, statusfilter.FilterContextThread, filters, - mutes, ) // Convert and filter the thread context descendants @@ -335,7 +315,6 @@ func (p *Processor) ContextGet( threadContext.descendants, statusfilter.FilterContextThread, filters, - mutes, ) return &apiContext, nil @@ -352,8 +331,8 @@ func (p *Processor) WebContextGet( targetStatusID string, ) (*apimodel.WebThreadContext, gtserror.WithCode) { // Retrieve the internal thread context. - iCtx, errWithCode := p.contextGet( - ctx, + iCtx, errWithCode := p.contextGet(ctx, + nil, // No authed requester. targetStatusID, ) -- cgit v1.2.3