Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View performance (+ memcached question) #3227

Closed
wants to merge 3 commits into from
Closed
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
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ gem 'will_paginate-bootstrap', '>= 1.0.1'
gem 'jquery-atwho-rails'
# To implement incoming mail processing microframework
gem 'mailman', require: false
gem 'dalli'

# To convert html to markdown
gem 'reverse_markdown'
Expand Down
7 changes: 7 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ GEM
thor (~> 0.19.4)
tins (~> 1.6)
crass (1.0.4)
dalli (2.7.8)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
diff-lcs (1.3)
Expand Down Expand Up @@ -401,6 +402,10 @@ GEM
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
skylight (2.0.2)
skylight-core (= 2.0.2)
skylight-core (2.0.2)
activesupport (>= 4.2.0)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand Down Expand Up @@ -468,6 +473,7 @@ DEPENDENCIES
coffee-rails (~> 4.2.2)
composite_primary_keys
coveralls
dalli
execjs
figaro
friendly_id
Expand Down Expand Up @@ -532,6 +538,7 @@ DEPENDENCIES
sass-rails (~> 5.0, >= 5.0.7)
scrypt (~> 3)
sidekiq
skylight
sqlite3
teaspoon-mocha
test-unit
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,11 @@ def reset_user_password
def useremail
if current_user && (current_user.role == 'moderator' || current_user.role == 'admin')
if params[:address]
# address was submitted. find the username(s) and return.
@address = params[:address]
@users = User.where(email: params[:address])
.where(status: [1, 4])
end
else
# unauthorized. instead of return ugly 403, just send somewhere else
redirect_to '/dashboard'
end
end
Expand Down
56 changes: 33 additions & 23 deletions app/views/notes/_notes.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<% notes = notes || @notes # accept local if present, default to instance %>
<div id="notes">
<div class="row">
<div class="row">
<% notes.each_with_index do |node,i| %>
<div class="<% if @widget %>col-xs-3 col-sm-3 <% end %><%= node.tagnames_as_classes %> col-md-3 clearfix node note node-nid-<%= node.id %> note-nid-<%= node.id %><% if node.status == 4 %> moderated<% end %>" style="overflow:hidden; text-align:center">
<% cache node do %>
<div class="<% if @widget %>col-xs-3 col-sm-3 <% end %><%= node.tagnames_as_classes %> col-md-3 clearfix node note node-nid-<%= node.id %> note-nid-<%= node.id %><% if node.status == 4 %> moderated<% end %>" style="overflow:hidden; text-align:center">

<% if node.main_image %>
<a class="img" <% if @widget %>target="_blank"<% end %> href="<%= node.path %>"><img src="<%= node.main_image.path(:default) %>" style="width:100%;" /></a>
Expand All @@ -22,25 +23,26 @@

<h3><a <% if @widget %>target="_blank"<% end %> href="<%= node.path %>"><%= (node.type == 'note') ? node.title : node.latest.title %></a></h3>

<p class="meta"><small>
<% if node.type == 'note' %>
by <a <% if @widget %>target="_blank"<% end %> href="/profile/<%= node.author.name %>"><%= node.author.name %></a> <%= node.author.new_author_contributor %>
<%= distance_of_time_in_words(node.created_at, Time.current, { include_seconds: false, scope:'datetime.time_ago_in_words' }) %>
| <a <% if @widget %>target="_blank"<% end %> href="<%= node.path %>#comments"><i style="color:#888;" class="fa fa-comment-o"></i> <%= node.comment_count %></a>
<% else %>
<%= t('notes._notes.last_edit_by') %> <a <% if @widget %>target="_blank"<% end %> href="/profile/<%= node.latest.author.name %>"><%= node.latest.author.name %></a>
<%= distance_of_time_in_words(Time.at(node.latest.timestamp), Time.current, { include_seconds: false, scope: 'datetime.time_ago_in_words' }) %>
<% end %>
| <i class="fa fa-eye"></i> <%= number_with_delimiter(node.totalviews) %> <span class="hidden-xs hidden-sm"><%= t('notes._notes.views') %></span>
| <i style="<% if node.likes > 0 %>color:#db4;<% else %>color:#888;<% end %>" class="fa fa-star-o"></i> <%= node.likes %>
</small></p>
<p class="meta">
<small>
<% if node.type == 'note' %>
by <a <% if @widget %>target="_blank"<% end %> href="/profile/<%= node.author.name %>"><%= node.author.name %></a> <%= node.author.new_author_contributor %>
<%= distance_of_time_in_words(node.created_at, Time.current, { include_seconds: false, scope:'datetime.time_ago_in_words' }) %>
| <a <% if @widget %>target="_blank"<% end %> href="<%= node.path %>#comments"><i style="color:#888;" class="fa fa-comment-o"></i> <%= node.comment_count %></a>
<% else %>
<%= t('notes._notes.last_edit_by') %> <a <% if @widget %>target="_blank"<% end %> href="/profile/<%= node.latest.author.name %>"><%= node.latest.author.name %></a>
<%= distance_of_time_in_words(Time.at(node.latest.timestamp), Time.current, { include_seconds: false, scope: 'datetime.time_ago_in_words' }) %>
<% end %>
| <i class="fa fa-eye"></i> <%= number_with_delimiter(node.totalviews) %> <span class="hidden-xs hidden-sm"><%= t('notes._notes.views') %></span>
| <i style="<% if node.likes > 0 %>color:#db4;<% else %>color:#888;<% end %>" class="fa fa-star-o"></i> <%= node.likes %>
</small>
</p>

<div class="content">
<% if @compact.nil? %>
<% if params[:action].to_s.include?("methods") %>
<p><small>
<a <% if @widget %>target="_blank"<% end %> href="<%= node.path %>#Activities"><i class="fa fa-flask" style="color:#3da56a;"></i> <%= node.activities.count %> activities</a> &nbsp;
<!-- <p><i class="fa fa-users" style="color:blue"></i> contributors</p> -->
<a <% if @widget %>target="_blank"<% end %> href="<%= node.path %>#Questions"><i class="fa fa-question-circle" style="color:#db3a1e;"></i> <span id="questions-count-<%= node.id %>"><%= node.questions.count %> questions</span></a>
</small></p>
<% else %>
Expand All @@ -56,15 +58,23 @@
<% end %>
<hr style="display:none;" class="bottom" />
</div>

</div>
<% unless @widget %><hr class="visible-xs visible-sm" /><% end %>
<% if ((i+1)/4.0).to_i == ((i+1)/4.0) %>
</div>
<% unless @widget %><hr class="visible-xs visible-sm grid" /><% end %>
<div class="row">
<% end %>

<% unless @widget %>
<hr class="visible-xs visible-sm" />
<% end %>

<% if ((i+1)/4.0).to_i == ((i+1)/4.0) %>
</div>
<% unless @widget %>
<hr class="visible-xs visible-sm grid" />
<% end %>
<div class="row">
<% end %>

<% end %>
<% end %>
</div>
</div>
</div>

<%= will_paginate notes, :renderer => BootstrapPagination::Rails unless @unpaginated %>
3 changes: 2 additions & 1 deletion app/views/users/profile.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@

<% if @profile_user && current_user && @profile_user == current_user %>
<%= form_tag "/users/test_digest_email", method: :post do %>
<%= submit_tag "Test Digest Email" %>
<br />
<%= submit_tag "Test Digest Email", class: 'btn btn-primary' %>
<% end %>
<% end %>

Expand Down
3 changes: 1 addition & 2 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
# Use a different logger for distributed setups
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)

# Use a different cache store in production
# config.cache_store = :mem_cache_store
config.cache_store = :dalli_store

# Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter = :resque
Expand Down