Commit 0eef9881 authored by Tiago Botelho's avatar Tiago Botelho

Removes MultiFileEditor

This file was responsible for logging
Web IDE commits.

This commit is also responsible for removing the
IDE feature flag entirely
parent c07d12fb
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180917172041) do
ActiveRecord::Schema.define(version: 20180924141949) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......
......@@ -76,7 +76,6 @@ class License < ActiveRecord::Base
cluster_health
dast
epics
ide
chatops
pod_logs
pseudonymizer
......
module Gitlab
module Metrics
class MultiFileEditor
delegate :total, to: :commit_stats, prefix: :line_changes
def initialize(project, current_user, commit)
@project, @current_user, @commit = project, current_user, commit
end
def log
return unless ::License.feature_available?(:ide)
Rails.logger.info("Web editor usage - #{metric_info}")
end
private
def files_total
@commit.diffs.size
end
def commit_stats
@commit.stats
end
def metric_info
"ide_usage_project_id: #{@project.id}, ide_usage_user: #{@current_user.id}, ide_usage_line_count: #{line_changes_total}, ide_usage_file_count: #{files_total}"
end
end
end
end
require 'spec_helper'
describe Gitlab::Metrics::MultiFileEditor do
set(:project) { create(:project, :repository) }
let(:user) { create(:user) }
subject { described_class.new(project, user, project.commit('b83d6e391c22777fca1ed3012fce84f633d7fed0')) }
describe '.log' do
it 'has the right log info' do
stub_licensed_features(ide: true)
info = "Web editor usage - ide_usage_project_id: #{project.id}, ide_usage_user: #{user.id}, ide_usage_line_count: 1, ide_usage_file_count: 1"
expect(Rails.logger).to receive(:info).with(info)
subject.log
end
it 'does not log any info if IDE is disabled' do
info = "Web editor usage - ide_usage_project_id: #{project.id}, ide_usage_user: #{user.id}, ide_usage_line_count: 1, ide_usage_file_count: 1"
expect(Rails.logger).not_to receive(:info).with(info)
subject.log
end
end
end
......@@ -111,10 +111,7 @@ module API
if result[:status] == :success
commit_detail = user_project.repository.commit(result[:result])
if find_user_from_warden
Gitlab::WebIdeCommitsCounter.increment
::Gitlab::Metrics::MultiFileEditor.new(user_project, current_user, commit_detail).log
end
Gitlab::WebIdeCommitsCounter.increment if find_user_from_warden
present commit_detail, with: Entities::CommitDetail
else
......
......@@ -302,14 +302,6 @@ describe API::Commits do
expect(json_response['committer_email']).to eq(user.email)
end
it 'does not call the metrics using access token authentication' do
stub_licensed_features(ide: true)
post api(url, user), valid_c_params
expect_any_instance_of(::Gitlab::Metrics::MultiFileEditor).not_to receive(:record)
end
it 'returns a 400 bad request if file exists' do
post api(url, user), invalid_c_params
......
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