Provide code review ID for diff files

What does this MR do and why?

Backend part of a fix for Dangerous "Viewed" state prefetch behavior in M... (#582822).

This MR adds code_review_id property to DiffFile, then exposed in diffs_batch.json and diffs_metadata.json requests.

This ID is a port of the existing client-generated diff file ID, which is used to mark files during code review.

Because this ID was generated on the client-side we couldn't use it to mark viewed files in file-by-file mode, which doesn't load all files. Generation of this ID depends on data that is present only when a diff file is loaded, which is not available for all files in file-by-file mode.

The server-side code_review_id solves that problem: this ID is now present for both diff file and file browser requests. That means we no longer need to load each diff file in order to know if it was reviewed before reflecting that status in a file browser.

How to set up and validate locally

  1. Go to any merge request
  2. Open network panel
  3. Go to 'Changes' tab
  4. Observe both diffs_batch.json and diffs_metadata.json to contain code_review_id for diff files

Merge request reports

Loading