Commit b173ae6b authored by Rémy Coutable's avatar Rémy Coutable

Fix linting, route, and specs

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent af0c6917
import 'vendor/peek'; import 'vendor/peek';
import 'vendor/peek.performance_bar'; import 'vendor/peek.performance_bar';
$(document).on('click', '#peek-show-queries', function(e) { $(document).on('click', '#peek-show-queries', (e) => {
e.preventDefault(); e.preventDefault();
$('.peek-rblineprof-modal').hide(); $('.peek-rblineprof-modal').hide();
let $modal = $('#modal-peek-pg-queries'); const $modal = $('#modal-peek-pg-queries');
if ($modal.length) { if ($modal.length) {
$modal.modal('toggle'); $modal.modal('toggle');
} }
}); });
$(document).on('click', '.js-lineprof-file', function(e) { $(document).on('click', '.js-lineprof-file', (e) => {
e.preventDefault(); e.preventDefault();
$(this).parents('.heading').next('div').toggle(); $(this).parents('.heading').next('div').toggle();
}); });
...@@ -19,7 +19,7 @@ class ApplicationController < ActionController::Base ...@@ -19,7 +19,7 @@ class ApplicationController < ActionController::Base
before_action :ldap_security_check before_action :ldap_security_check
before_action :sentry_context before_action :sentry_context
before_action :default_headers before_action :default_headers
before_action :add_gon_variables, unless: -> { request.path.start_with?('/peek') } before_action :add_gon_variables, unless: -> { request.path.start_with?('/-/peek') }
before_action :configure_permitted_parameters, if: :devise_controller? before_action :configure_permitted_parameters, if: :devise_controller?
before_action :require_email, unless: :devise_controller? before_action :require_email, unless: :devise_controller?
......
%strong %strong
%a#peek-show-queries{ href: '#' } %a#peek-show-queries{ href: '#' }
%span{ data: { defer_to: "#{view.defer_key}-duration" }}... %span{ data: { defer_to: "#{view.defer_key}-duration" } }...
\/ \/
%span{ data: { defer_to: "#{view.defer_key}-calls" }}... %span{ data: { defer_to: "#{view.defer_key}-calls" } }...
#modal-peek-pg-queries.modal{ tabindex: -1 } #modal-peek-pg-queries.modal{ tabindex: -1 }
.modal-dialog .modal-dialog
#modal-peek-pg-queries-content.modal-content #modal-peek-pg-queries-content.modal-content
...@@ -10,5 +10,5 @@ ...@@ -10,5 +10,5 @@
%a.close{ href: "#", "data-dismiss" => "modal" } × %a.close{ href: "#", "data-dismiss" => "modal" } ×
%h4 %h4
SQL queries SQL queries
.modal-body{ data: { defer_to: "#{view.defer_key}-queries" }}... .modal-body{ data: { defer_to: "#{view.defer_key}-queries" } }...
pg pg
...@@ -17,6 +17,7 @@ Peek.into Peek::Views::Sidekiq ...@@ -17,6 +17,7 @@ Peek.into Peek::Views::Sidekiq
Peek.into Peek::Views::Rblineprof Peek.into Peek::Views::Rblineprof
Peek.into Peek::Views::GC Peek.into Peek::Views::GC
# rubocop:disable Style/ClassAndModuleCamelCase
class PEEK_DB_CLIENT class PEEK_DB_CLIENT
class << self class << self
attr_accessor :query_details attr_accessor :query_details
...@@ -24,5 +25,4 @@ class PEEK_DB_CLIENT ...@@ -24,5 +25,4 @@ class PEEK_DB_CLIENT
self.query_details = Concurrent::Array.new self.query_details = Concurrent::Array.new
end end
# rubocop:disable Style/ClassAndModuleCamelCase
PEEK_DB_VIEW.prepend ::Gitlab::PerformanceBar::PeekQueryTracker PEEK_DB_VIEW.prepend ::Gitlab::PerformanceBar::PeekQueryTracker
...@@ -11,7 +11,6 @@ Rails.application.routes.draw do ...@@ -11,7 +11,6 @@ Rails.application.routes.draw do
post :toggle_award_emoji, on: :member post :toggle_award_emoji, on: :member
end end
mount Peek::Railtie => '/peek'
draw :sherlock draw :sherlock
draw :development draw :development
draw :ci draw :ci
...@@ -43,6 +42,7 @@ Rails.application.routes.draw do ...@@ -43,6 +42,7 @@ Rails.application.routes.draw do
get 'liveness' => 'health#liveness' get 'liveness' => 'health#liveness'
get 'readiness' => 'health#readiness' get 'readiness' => 'health#readiness'
resources :metrics, only: [:index] resources :metrics, only: [:index]
mount Peek::Railtie => '/peek'
end end
# Koding route # Koding route
......
...@@ -20,8 +20,8 @@ describe Commit, models: true do ...@@ -20,8 +20,8 @@ describe Commit, models: true do
end end
it 'caches the author' do it 'caches the author' do
allow(RequestStore).to receive(:active?).and_return(true)
user = create(:user, email: commit.author_email) user = create(:user, email: commit.author_email)
expect(RequestStore).to receive(:active?).and_return(true)
expect_any_instance_of(Commit).to receive(:find_author_by_any_email).and_call_original expect_any_instance_of(Commit).to receive(:find_author_by_any_email).and_call_original
expect(commit.author).to eq(user) expect(commit.author).to eq(user)
......
let requestId = null;
(function($) { (function($) {
var fetchRequestResults, getRequestId, peekEnabled, toggleBar, updatePerformanceBar; var fetchRequestResults, getRequestId, peekEnabled, toggleBar, updatePerformanceBar;
getRequestId = function() { getRequestId = function() {
if (requestId != null) { return $('#peek').data('request-id');
return requestId;
} else {
return $('#peek').data('request-id');
}
}; };
peekEnabled = function() { peekEnabled = function() {
return $('#peek').length; return $('#peek').length;
...@@ -64,7 +58,7 @@ let requestId = null; ...@@ -64,7 +58,7 @@ let requestId = null;
} }
}; };
fetchRequestResults = function() { fetchRequestResults = function() {
return $.ajax('/peek/results', { return $.ajax('/-/peek/results', {
data: { data: {
request_id: getRequestId() request_id: getRequestId()
}, },
......
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