Commit 977a5e85 authored by Pavel Shutsin's avatar Pavel Shutsin

Consider first_reassigned_at for code review analytics

Code review cycle should be started when
merge request was reassigned for the first time
parent e0bf321b
...@@ -7,7 +7,7 @@ module EE ...@@ -7,7 +7,7 @@ module EE
class_methods do class_methods do
def review_time_field def review_time_field
@review_time_field ||= Arel.sql("LEAST(merge_request_metrics.first_comment_at, merge_request_metrics.first_approved_at)") @review_time_field ||= Arel.sql("LEAST(merge_request_metrics.first_comment_at, merge_request_metrics.first_approved_at, merge_request_metrics.first_reassigned_at)")
end end
end end
...@@ -18,7 +18,7 @@ module EE ...@@ -18,7 +18,7 @@ module EE
end end
def review_start_at def review_start_at
[first_comment_at, first_approved_at].compact.min [first_comment_at, first_approved_at, first_reassigned_at].compact.min
end end
def review_end_at def review_end_at
......
---
title: Consider MR reassign as code review start
merge_request: 26891
author:
type: changed
...@@ -4,11 +4,12 @@ require 'spec_helper' ...@@ -4,11 +4,12 @@ require 'spec_helper'
describe MergeRequest::Metrics do describe MergeRequest::Metrics do
describe '#review_start_at' do describe '#review_start_at' do
it 'is the earliest date from first_comment_at or first_approved_at' do it 'is the earliest date from first_comment_at, first_approved_at or first_reassigned_at' do
subject.first_approved_at = 1.day.ago subject.first_approved_at = 1.hour.ago
subject.first_comment_at = 1.hour.ago subject.first_comment_at = 1.day.ago
subject.first_reassigned_at = 1.week.ago
expect(subject.review_start_at).to be_like_time(1.day.ago) expect(subject.review_start_at).to be_like_time(1.week.ago)
end end
context 'when all review start candidates are nil' do context 'when all review start candidates are nil' do
...@@ -20,6 +21,7 @@ describe MergeRequest::Metrics do ...@@ -20,6 +21,7 @@ describe MergeRequest::Metrics do
context 'when one of review start candidates is nil' do context 'when one of review start candidates is nil' do
it 'is earliest date from non-nil values' do it 'is earliest date from non-nil values' do
subject.first_approved_at = 1.day.ago subject.first_approved_at = 1.day.ago
subject.first_reassigned_at = 1.hour.ago
expect(subject.review_start_at).to be_like_time(1.day.ago) expect(subject.review_start_at).to be_like_time(1.day.ago)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment