buro9 / microcosm

Front end for Microcosm, a Go web server that serves the static files, templates and performs API calls.
GNU Affero General Public License v3.0
11 stars 3 forks source link

Refactor the fetching of comments in the API to always retrieve the attachments #132

Open buro9 opened 1 year ago

buro9 commented 1 year ago

Currently, when fetching a page of comments, i.e. within a conversation... the attachments have to be fetched per comments.

This means for a page of 25 comments there are potentially up to 25 additional API calls occurring, one per comment, to retrieve the attachments.

This does not seem ideal given that in nearly all cases fetching the comment requires fetching the attachments... and in the occasions where it does not these are the least frequently called paths. i.e. Reads of conversation pages happen 10,000x more than an edit of a comment... yet we're doing more work by fetching attachments per comment on the read path as it involves distinct API calls.