Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
- name: Ruby gem cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
Expand All @@ -37,7 +37,7 @@ jobs:
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: JS package cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
- name: Ruby gem cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
Expand All @@ -110,7 +110,7 @@ jobs:
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: JS package cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ coverage
dump.rdb
package-lock.json
.DS_Store
.cursor/
18 changes: 7 additions & 11 deletions app/controllers/development_metrics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ def repositories

build_metrics(repository.id, entity_name)
build_metrics_definitions
build_success_rates(entity_name)
build_overall_calculations(entity_name)

@code_owners = repository.code_owners.pluck(:login)
@code_climate = code_climate_repository_summary
end

def departments
Expand All @@ -31,7 +30,7 @@ def departments
entity_name = Department.name

build_metrics(department.id, entity_name)
build_success_rates(entity_name)
build_overall_calculations(entity_name)
@code_climate = code_climate_department_summary
@overview = department_overview
end
Expand All @@ -46,18 +45,19 @@ def products_metrics

private

def build_success_rates(entity_name)
def build_overall_calculations(entity_name)
key = "per_#{entity_name.downcase}_distribution".to_sym

@merge_time_success_rate = @merge_time[key].first[:success_rate]
@review_turnaround_success_rate = @review_turnaround[key].first[:success_rate]
merge_time = @merge_time[key].first
@merge_time_success_rate = merge_time[:success_rate]
@merge_time_avg = merge_time[:avg]
@pull_request_size_avg = @pull_request_size[key].first[:avg]
end

def build_metrics(entity_id, entity_name)
validate_from_to(from: metric_params[:from], to: metric_params[:to])
metrics = Builders::Chartkick::DevelopmentMetrics.const_get(entity_name)
.call(entity_id, @from, @to)
@review_turnaround = metrics[:review_turnaround]
@merge_time = metrics[:merge_time]
@pull_request_size = metrics[:pull_request_size]
end
Expand Down Expand Up @@ -165,10 +165,6 @@ def action
@action ||= params[:action]
end

def code_climate_repository_summary
CodeClimateSummaryRetriever.call(repository.id)
end

def code_climate_department_summary
CodeClimate::RepositoriesSummaryService.call(
department: department,
Expand Down
7 changes: 0 additions & 7 deletions app/jobs/jira_defect_metrics_updater_job.rb

This file was deleted.

7 changes: 0 additions & 7 deletions app/jobs/open_source_metrics_updater_job.rb

This file was deleted.

3 changes: 3 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ def name
.or(where(company_member_until: date..Time.current))
}

scope :bot_users, -> { where('login ILIKE ?', '%[bot]%') }
scope :ignored_users, -> { bot_users.or(where(login: SettingsService.ignored_users)) }

RANSACK_ATTRIBUTES = %w[company_member_since company_member_until created_at github_id id
id_value login node_id updated_at].freeze
end
4 changes: 2 additions & 2 deletions app/services/builders/chartkick/development_metrics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module Chartkick
class DevelopmentMetrics < BaseService
def initialize(entity_id, from, to)
@entity_id = entity_id
@from = from
@to = to
@from = from&.to_datetime&.beginning_of_day
@to = to&.to_datetime&.end_of_day
end

def call
Expand Down
20 changes: 18 additions & 2 deletions app/services/builders/chartkick/repository_distribution_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ def call
[{
name: repository_name,
data: intervals,
success_rate: build_success_rate(repository_name, metric_name, intervals)
success_rate: build_success_rate(repository_name, metric_name, intervals),
avg: build_average
}]
end

Expand All @@ -18,7 +19,10 @@ def repository_name
end

def retrieve_records
metric.retrieve_records(entity_id: @entity_id, time_range: @query[:value_timestamp])
@retrieve_records ||= metric.retrieve_records(
entity_id: @entity_id,
time_range: @query[:value_timestamp]
)
end

def metric_name
Expand All @@ -32,6 +36,18 @@ def metric
def resolve_interval(entity)
metric.resolve_interval(entity)
end

def build_average
return if retrieve_records.empty?

total_value = retrieve_records.sum { |record| metric.value_for_average(record) }
total_records = retrieve_records.count

{
avg_number: (total_value.to_f / total_records).round(1),
total: total_records
}
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ def retrieve_records(entity_id:, time_range:)
.joins(pull_request: :repository)
.where(repositories: { id: entity_id })
.where(events_pull_requests: { merged_at: time_range })
.where.not(events_pull_requests: { owner: User.ignored_users })
end

def resolve_interval(entity)
Metrics::IntervalResolver::Time.call(entity.value_as_hours)
end

def value_for_average(entity)
entity.value_as_hours
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ def retrieve_records(entity_id:, time_range:)
.where(repository_id: entity_id)
.where(opened_at: time_range)
.where.not(size: nil)
.where.not(owner: User.ignored_users)
end

def resolve_interval(entity)
Metrics::IntervalResolver::PrSize.call(entity.size)
end

def value_for_average(entity)
entity.size
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ def retrieve_records(entity_id:, time_range:)
def resolve_interval(entity)
Metrics::IntervalResolver::Time.call(entity.value_as_hours)
end

def value_for_average(entity)
entity.value_as_hours
end
end
end
end
Expand Down
11 changes: 0 additions & 11 deletions app/services/code_climate_summary_retriever.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/services/metrics/group/weekly.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def interval
def value_timestamp
from = @from || 4.weeks.ago.strftime('%Y-%m-%d')
to = @to || Time.zone.now.strftime('%Y-%m-%d')
from.to_date..to.to_date
from..to
end
end
end
Expand Down
9 changes: 0 additions & 9 deletions app/services/processors/blog_metrics_full_updater.rb

This file was deleted.

9 changes: 0 additions & 9 deletions app/services/processors/blog_metrics_partial_updater.rb

This file was deleted.

20 changes: 0 additions & 20 deletions app/services/processors/blog_metrics_updater.rb

This file was deleted.

75 changes: 0 additions & 75 deletions app/services/processors/blog_post_views_updater.rb

This file was deleted.

5 changes: 0 additions & 5 deletions app/services/processors/blog_posts_full_updater.rb

This file was deleted.

8 changes: 0 additions & 8 deletions app/services/processors/blog_posts_partial_updater.rb

This file was deleted.

Loading
Loading