Make the UpdateHeadPipelineForMergeRequestWorker idempotent

Part of #178 (closed)

The UpdateHeadPipelineForMergeRequestWorker processed 238k "duplicate" jobs the past 7 days, and spent 3 hours on that. Duplicate jobs are jobs that get scheduled when there is already a job in the queue for the same worker with the same arguments.

If the job was (marked as) idempotent, we would be able to deduplicate those jobs when they get scheduled.

This finds the latest pipeline for a the diff head of a merge request and makes it accessible through a faster query. It is already idempotent, can be marked as such with the appropriate specs.

Edited by Bob Van Landuyt