Skip to content

Change all occurrences of ApplicationHelper#avatar_icon to use a User object where possible

Andreas Brandl requested to merge 42800-change-usage-of-avatar_icon into master

What does this MR do?

As proposed over here, this

  1. Removes ApplicationHelper#avatar_icon and
  2. introduces more specific #avatar_icon_for_user and #avatar_icon_for_email.
  3. Change to use #avatar_icon_for_user over _for_email where possible.

While the explicit #avatar_icon_for_user and #avatar_icon_for_email makes it less convenient to use than the generic one, it also makes it harder to introduce unnecessary database calls (or at least, it's easier to spot them).

Additionally, it adds eager loading for authors in corresponding finders for Note and Issue types.

Are there points in the code the reviewer needs to double check?

I'm not too sure about the added eager loading for authors as those finders are quite generic (see comment below).

Why was this MR needed?

We want to make it harder for callers of #avatar_icon to run into N+1 problems and unnecessary queries to find a user when given an email address.

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Closes #42800 (closed)

Edited by Yorick Peterse

Merge request reports