From eaa191515e52f50eeb64a0861685aed5a77d5519 Mon Sep 17 00:00:00 2001 From: danielgrippi <danielgrippi@gmail.com> Date: Fri, 30 Sep 2011 21:11:00 -0700 Subject: [PATCH] remove logging statement in a before filter that performed a query --- app/controllers/application_controller.rb | 31 +++++----- app/views/layouts/_header.html.haml | 69 +++++++++++------------ 2 files changed, 47 insertions(+), 53 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 06fc5e52a9..137590998b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -4,28 +4,35 @@ class ApplicationController < ActionController::Base has_mobile_fu + protect_from_forgery :except => :receive + before_filter :ensure_http_referer_is_set - before_filter :set_header_data, :except => [:create, :update] + before_filter :set_header_data, :except => [:create, :update, :destroy] before_filter :set_locale before_filter :set_git_header if (AppConfig[:git_update] && AppConfig[:git_revision]) - before_filter :which_action_and_user - prepend_before_filter :clear_gc_stats before_filter :set_grammatical_gender + prepend_before_filter :clear_gc_stats + inflection_method :grammatical_gender => :gender - helper_method :all_aspects, :all_contacts_count, :my_contacts_count, :only_sharing_count - helper_method :tags, :tag_followings + helper_method :all_aspects, + :all_contacts_count, + :my_contacts_count, + :only_sharing_count, + :tag_followings, + :tags def ensure_http_referer_is_set request.env['HTTP_REFERER'] ||= '/aspects' end + # we need to do this for vanna controller. these should really be controller + # helper methods instead def set_header_data if user_signed_in? if request.format.html? && !params[:only_posts] - @aspect = nil @notification_count = Notification.for(current_user, :unread =>true).count @unread_message_count = ConversationVisibility.sum(:unread, :conditions => "person_id = #{current_user.person.id}") end @@ -69,18 +76,6 @@ class ApplicationController < ActionController::Base headers['X-Git-Revision'] = AppConfig[:git_revision] end - def which_action_and_user - str = "event=request_with_user controller=#{self.class} action=#{self.action_name} " - if current_user - str << "uid=#{current_user.id} " - str << "user_created_at='#{current_user.created_at.to_date.to_s}' user_created_at_unix=#{current_user.created_at.to_i} " if current_user.created_at - str << "user_non_pending_contact_count=#{current_user.contacts.size} user_contact_count=#{Contact.unscoped.where(:user_id => current_user.id).size} " - else - str << 'uid=nil' - end - Rails.logger.info str - end - def set_locale if user_signed_in? I18n.locale = current_user.language diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index d60f95066e..84a136d392 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -21,47 +21,46 @@ = form_tag(people_path, :method => 'get', :class => "search_form") do = text_field_tag 'q', nil, :placeholder => t('find_people'), :type => 'search', :results => 5 - - if @notification_count - #nav_badges - #home_badge.badge - = link_to aspects_path, :title => t('_home') do - = image_tag 'icons/home_grey.svg', :height => 16 + #nav_badges + #home_badge.badge + = link_to aspects_path, :title => t('_home') do + = image_tag 'icons/home_grey.svg', :height => 16 - #contacts_badge.badge - = link_to contacts_link, :title => t('_contacts') do - = image_tag 'icons/contacts_grey.svg', :height => 16 + #contacts_badge.badge + = link_to contacts_link, :title => t('_contacts') do + = image_tag 'icons/contacts_grey.svg', :height => 16 - #notification_badge.badge - = link_to notifications_path, :title => new_notification_text(@notification_count) do - = image_tag 'icons/notifications_grey.svg', :height => 16, :id => "notification-flag" - .badge_count{:class => ("hidden" if @notification_count == 0)} - = @notification_count + #notification_badge.badge + = link_to notifications_path, :title => new_notification_text(@notification_count) do + = image_tag 'icons/notifications_grey.svg', :height => 16, :id => "notification-flag" + .badge_count{:class => ("hidden" if @notification_count == 0)} + = @notification_count - #message_inbox_badge.badge - = link_to conversations_path , :title => new_message_text(@unread_message_count) do - = image_tag 'icons/mail_grey.svg', :width => 18 - .badge_count{:class => ("hidden" if @unread_message_count == 0)} - = @unread_message_count + #message_inbox_badge.badge + = link_to conversations_path , :title => new_message_text(@unread_message_count) do + = image_tag 'icons/mail_grey.svg', :width => 18 + .badge_count{:class => ("hidden" if @unread_message_count == 0)} + = @unread_message_count - #notification_dropdown - .header - = link_to t('.view_all'), notifications_path, :id => "view_all_notifications" - %h4 - = t('.recent_notifications') - .notifications - .ajax_loader - = image_tag("ajax-loader.gif") + #notification_dropdown + .header + = link_to t('.view_all'), notifications_path, :id => "view_all_notifications" + %h4 + = t('.recent_notifications') + .notifications + .ajax_loader + = image_tag("ajax-loader.gif") - #hovercard_container - #hovercard - %img.avatar - %h4 - %a.person - #hovercard_dropdown_container + #hovercard_container + #hovercard + %img.avatar + %h4 + %a.person + #hovercard_dropdown_container - .hovercard_footer - .footer_container - .hashtags + .hovercard_footer + .footer_container + .hashtags #lightbox #lightbox-content -- GitLab