Module: BlameHelper

Included in:
Gitlab::BlamePresenter
Defined in:
app/helpers/blame_helper.rb

Instance Method Summary collapse

Instance Method Details

#age_map_class(commit_date, duration) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/helpers/blame_helper.rb', line 15

def age_map_class(commit_date, duration)
  if duration[:started_days_ago] == 0
    "blame-commit-age-0"
  else
    commit_date_days_ago = (duration[:now] - commit_date).to_i / 1.day
    # Numbers 0 to 10 come from this calculation, but only commits on the oldest
    # day get number 10 (all other numbers can be multiple days), so the range
    # is normalized to 0-9
    age_group = [(10 * commit_date_days_ago) / duration[:started_days_ago], 9].min
    "blame-commit-age-#{age_group}"
  end
end

#age_map_duration(blame_groups, project) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'app/helpers/blame_helper.rb', line 4

def age_map_duration(blame_groups, project)
  now = Time.zone.now
  start_date = blame_groups.map { |blame_group| blame_group[:commit].committed_date }
    .append(project.created_at).min

  {
    now: now,
    started_days_ago: (now - start_date).to_i / 1.day
  }
end

#blame_pages_streaming_url(id, project) ⇒ Object



28
29
30
# File 'app/helpers/blame_helper.rb', line 28

def blame_pages_streaming_url(id, project)
  namespace_project_blame_page_url(namespace_id: project.namespace, project_id: project, id: id, streaming: true)
end

#entire_blame_path(id, project) ⇒ Object



32
33
34
# File 'app/helpers/blame_helper.rb', line 32

def entire_blame_path(id, project)
  namespace_project_blame_streaming_path(namespace_id: project.namespace, project_id: project, id: id)
end