Commit 48cf97e8 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'cache-events' into 'master'

Cache all events

Use CSS to determine if the current user needs to see "Congratulations! Tweet about it" by project creation events and "Create Merge Request" by push events.

Implemented as described here: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/911#note_1559710

Addresses #2054, in part.

cc @dzaporozhets 

See merge request !1103
parents a71bed53 9bd074d4
...@@ -43,6 +43,7 @@ v 7.14.0 (unreleased) ...@@ -43,6 +43,7 @@ v 7.14.0 (unreleased)
- Fetch code from forks to refs/merge-requests/:id/head when merge request created - Fetch code from forks to refs/merge-requests/:id/head when merge request created
- Remove satellites - Remove satellites
- Remove comments and email addresses when publicly exposing ssh keys (Zeger-Jan van de Weg) - Remove comments and email addresses when publicly exposing ssh keys (Zeger-Jan van de Weg)
- Cache all events
v 7.13.3 v 7.13.3
- Fix bug causing Bitbucket importer to crash when OAuth application had been removed. - Fix bug causing Bitbucket importer to crash when OAuth application had been removed.
......
...@@ -3,13 +3,11 @@ ...@@ -3,13 +3,11 @@
.event-item-timestamp .event-item-timestamp
#{time_ago_with_tooltip(event.created_at)} #{time_ago_with_tooltip(event.created_at)}
- if event.created_project? = cache event, "v1" do
= cache [event, current_user] do
= image_tag avatar_icon(event.author_email, 24), class: "avatar s24", alt:'' = image_tag avatar_icon(event.author_email, 24), class: "avatar s24", alt:''
- if event.created_project?
= render "events/event/created_project", event: event = render "events/event/created_project", event: event
- else - elsif event.push?
= image_tag avatar_icon(event.author_email, 24), class: "avatar s24", alt:''
- if event.push?
= render "events/event/push", event: event = render "events/event/push", event: event
- elsif event.commented? - elsif event.commented?
= render "events/event/note", event: event = render "events/event/note", event: event
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
- else - else
= event.project_name = event.project_name
- if current_user == event.author && !event.project.private? && twitter_sharing_enabled? - if !event.project.private? && twitter_sharing_enabled?
.event-body .event-body{"data-user-is" => event.author_id}
.event-note .event-note
.md .md
%p %p
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
- few_commits.each do |commit| - few_commits.each do |commit|
= render "events/commit", commit: commit, project: project = render "events/commit", commit: commit, project: project
- create_mr = current_user == event.author && event.new_ref? && create_mr_button?(event.project.default_branch, event.ref_name, event.project) - create_mr = event.new_ref? && create_mr_button?(event.project.default_branch, event.ref_name, event.project)
- if event.commits_count > 1 - if event.commits_count > 1
%li.commits-stat %li.commits-stat
- if event.commits_count > 2 - if event.commits_count > 2
...@@ -34,10 +34,11 @@ ...@@ -34,10 +34,11 @@
Compare #{from_label}...#{truncate_sha(event.commit_to)} Compare #{from_label}...#{truncate_sha(event.commit_to)}
- if create_mr - if create_mr
%span{"data-user-is" => event.author_id, "data-display" => "inline"}
or or
= link_to create_mr_path(event.project.default_branch, event.ref_name, event.project) do = link_to create_mr_path(event.project.default_branch, event.ref_name, event.project) do
create a merge request create a merge request
- elsif create_mr - elsif create_mr
%li.commits-stat %li.commits-stat{"data-user-is" => event.author_id}
= link_to create_mr_path(event.project.default_branch, event.ref_name, event.project) do = link_to create_mr_path(event.project.default_branch, event.ref_name, event.project) do
Create Merge Request Create Merge Request
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
= favicon_link_tag 'touch-icon-ipad-retina.png', rel: 'apple-touch-icon', sizes: '152x152' = favicon_link_tag 'touch-icon-ipad-retina.png', rel: 'apple-touch-icon', sizes: '152x152'
-# Windows 8 pinned site tile -# Windows 8 pinned site tile
%meta{name: 'msapplication-TileImage', content: image_url('msapplication-tile.png')} %meta{name: 'msapplication-TileImage', content: image_path('msapplication-tile.png')}
%meta{name: 'msapplication-TileColor', content: '#30353E'} %meta{name: 'msapplication-TileColor', content: '#30353E'}
= yield :meta_tags = yield :meta_tags
...@@ -35,3 +35,5 @@ ...@@ -35,3 +35,5 @@
= render 'layouts/google_analytics' if extra_config.has_key?('google_analytics_id') = render 'layouts/google_analytics' if extra_config.has_key?('google_analytics_id')
= render 'layouts/piwik' if extra_config.has_key?('piwik_url') && extra_config.has_key?('piwik_site_id') = render 'layouts/piwik' if extra_config.has_key?('piwik_url') && extra_config.has_key?('piwik_site_id')
= render 'layouts/bootlint' if Rails.env.development? = render 'layouts/bootlint' if Rails.env.development?
= render 'layouts/user_styles'
:css
[data-user-is] {
display: none !important;
}
[data-user-is="#{current_user.try(:id)}"] {
display: block !important;
}
[data-user-is="#{current_user.try(:id)}"][data-display="inline"] {
display: inline !important;
}
[data-user-is-not] {
display: block !important;
}
[data-user-is-not][data-display="inline"] {
display: inline !important;
}
[data-user-is-not="#{current_user.try(:id)}"] {
display: none !important;
}
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