Ensure we filter system notes when looking for notes
Context
Applying the activity_filter flag @john.mcdonnell found in gitlab-org/quality/quality-engineering/team-tasks#3846 (comment 2778551818) (internal)
This will be particularly useful when using UniqueComment, as we are looking for automation notes we previously added in a resource (and we search ALL notes). See more details.
What does this MR do and why?
When searching for notes, ensure we filter system notes.
This significantly speeds up the notes lookup inside issues/MRs when the resource has a lot of system comments due to automation.
Expected impact & dry-runs
Benchmarking command
require 'benchmark'
# An issue with thousands of system comments
path = "/projects/278964/issues/444453/notes"
Benchmark.bm(15) do |x|
# 7664 results
x.report("without_filter") { Triage.api_client.get(path, query: { per_page: 100 }).auto_paginate.count }
# 3 results
x.report("with_filter") { Triage.api_client.get(path, query: { per_page: 100, activity_filter: 'only_comments' }).auto_paginate.count }
end
Results
Adding activity_filter: 'only_comments' made this query ~100x faster (from 156s → 1.5s)
user system total real
without_filter 2.467677 0.630943 3.098620 (156.392021)
with_filter 0.008676 0.003627 0.012303 ( 1.541138)
Edited by David Dieulivol