Add option to request partial accounts in grouped notifications API #31299
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This allows clients to request trimmed-down versions of accounts in the grouped notifications API to cut down on payload side and server CPU time.
To do this, it introduces a new
expand_accounts
parameters that currently has two possible values:full
(default, output full accounts in all cases) andpartial_avatars
which moves some of the accounts topartial_accounts
with a trimmed-down version.The fields for trimmed-down accounts are:
id
,acct
,avatar
andavatar_static
locked
,bot
,url
Example
Response
Benchmark
I did a small benchmark of a manufactured scenario of 20×(1 reblog + 1 like) notification from the same set of 10 (fairly simple, with no account fields and a short bio) accounts.
expand_accounts=full
takes around 385ms and returns a 334kb payload (before compression)expand_accounts=partial_avatars
takes around 203ms and returns a 186kb payload (before compression)