Commit 5071a971 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Rename remaining project_metrics to be project_statistics

parent 0828f69d
...@@ -14,8 +14,6 @@ module EE ...@@ -14,8 +14,6 @@ module EE
delegate :actual_shared_runners_minutes_limit, delegate :actual_shared_runners_minutes_limit,
:shared_runners_minutes_used?, to: :namespace :shared_runners_minutes_used?, to: :namespace
has_one :project_metrics, dependent: :destroy
end end
def shared_runners_available? def shared_runners_available?
......
...@@ -7,7 +7,7 @@ class ClearSharedRunnersMinutesWorker ...@@ -7,7 +7,7 @@ class ClearSharedRunnersMinutesWorker
def perform def perform
return unless try_obtain_lease return unless try_obtain_lease
ProjectMetrics.update_all( ProjectStatistics.update_all(
shared_runners_minutes: 0, shared_runners_minutes: 0,
shared_runners_minutes_last_reset: Time.now) shared_runners_minutes_last_reset: Time.now)
......
...@@ -212,7 +212,6 @@ project: ...@@ -212,7 +212,6 @@ project:
- path_locks - path_locks
- approver_groups - approver_groups
- route - route
- project_metrics
- statistics - statistics
award_emoji: award_emoji:
- awardable - awardable
......
...@@ -2,10 +2,8 @@ require 'spec_helper' ...@@ -2,10 +2,8 @@ require 'spec_helper'
describe Project, models: true do describe Project, models: true do
describe 'associations' do describe 'associations' do
it { is_expected.to have_one(:project_metrics).dependent(:destroy) } it { is_expected.to delegate_method(:shared_runners_minutes).to(:project_statistics) }
it { is_expected.to delegate_method(:shared_runners_minutes_last_reset).to(:project_statistics) }
it { is_expected.to delegate_method(:shared_runners_minutes).to(:project_metrics) }
it { is_expected.to delegate_method(:shared_runners_minutes_last_reset).to(:project_metrics) }
it { is_expected.to delegate_method(:actual_shared_runners_minutes_limit).to(:namespace) } it { is_expected.to delegate_method(:actual_shared_runners_minutes_limit).to(:namespace) }
it { is_expected.to delegate_method(:shared_runners_minutes_limit_enabled?).to(:namespace) } it { is_expected.to delegate_method(:shared_runners_minutes_limit_enabled?).to(:namespace) }
......
require 'spec_helper'
describe ProjectMetrics, models: true do
it { is_expected.to belong_to(:project) }
it { is_expected.to validate_presence_of(:project) }
end
...@@ -19,7 +19,7 @@ describe UpdateBuildMinutesService, services: true do ...@@ -19,7 +19,7 @@ describe UpdateBuildMinutesService, services: true do
it "creates a metrics and sets duration" do it "creates a metrics and sets duration" do
subject subject
expect(project.project_metrics.reload.shared_runners_minutes). expect(project.project_statistics.reload.shared_runners_minutes).
to eq(build.duration.to_i) to eq(build.duration.to_i)
expect(namespace.namespace_statistics.reload.shared_runners_minutes). expect(namespace.namespace_statistics.reload.shared_runners_minutes).
...@@ -28,14 +28,14 @@ describe UpdateBuildMinutesService, services: true do ...@@ -28,14 +28,14 @@ describe UpdateBuildMinutesService, services: true do
context 'when metrics are created' do context 'when metrics are created' do
before do before do
project.create_project_metrics(shared_runners_minutes: 100) project.create_project_statistics(shared_runners_minutes: 100)
namespace.create_namespace_metrics(shared_runners_minutes: 100) namespace.create_namespace_metrics(shared_runners_minutes: 100)
end end
it "updates metrics and adds duration" do it "updates metrics and adds duration" do
subject subject
expect(project.project_metrics.reload.shared_runners_minutes). expect(project.project_statistics.reload.shared_runners_minutes).
to eq(100 + build.duration.to_i) to eq(100 + build.duration.to_i)
expect(namespace.namespace_statistics.reload.shared_runners_minutes). expect(namespace.namespace_statistics.reload.shared_runners_minutes).
...@@ -50,7 +50,7 @@ describe UpdateBuildMinutesService, services: true do ...@@ -50,7 +50,7 @@ describe UpdateBuildMinutesService, services: true do
it "does not create metrics" do it "does not create metrics" do
subject subject
expect(project.project_metrics).to be_nil expect(project.project_statistics).to be_nil
expect(namespace.namespace_statistics).to be_nil expect(namespace.namespace_statistics).to be_nil
end end
end end
......
...@@ -12,18 +12,18 @@ describe ClearSharedRunnersMinutesWorker do ...@@ -12,18 +12,18 @@ describe ClearSharedRunnersMinutesWorker do
subject { worker.perform } subject { worker.perform }
context 'when project metrics are defined' do context 'when project metrics are defined' do
let!(:project_metrics) { create(:project_metrics, shared_runners_minutes: 100) } let!(:project_statistics) { create(:project_statistics, shared_runners_minutes: 100) }
it 'clears counters' do it 'clears counters' do
subject subject
expect(project_metrics.reload.shared_runners_minutes).to be_zero expect(project_statistics.reload.shared_runners_minutes).to be_zero
end end
it 'resets timer' do it 'resets timer' do
subject subject
expect(project_metrics.reload.shared_runners_minutes_last_reset).to be_like_time(Time.now) expect(project_statistics.reload.shared_runners_minutes_last_reset).to be_like_time(Time.now)
end end
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