Skip to content

Commit

Permalink
[frontend] Introduces ProjectLogEntry view
Browse files Browse the repository at this point in the history
If you just want to check what happened project wide in the last couple of
hours to find the cause of some problem. There is already the RSS feed for this
but it's harder to skim than a nice *cough* web view.
  • Loading branch information
hennevogel committed Mar 27, 2018
1 parent 2fc97dd commit 328067f
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/api/app/assets/stylesheets/webui/application/project.scss
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,7 @@ table.buildstatus {
th.buildstatus img {
margin-bottom: -3px;
}

nav.pagination {
text-align: center;
}
6 changes: 5 additions & 1 deletion src/api/app/controllers/webui/project_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Webui::ProjectController < Webui::WebuiController
:status, :maintained_projects,
:add_maintained_project_dialog, :add_maintained_project, :remove_maintained_project,
:maintenance_incidents, :unlock_dialog, :unlock, :save_person, :save_group, :remove_role,
:move_path, :save_prjconf, :clear_failed_comment]
:move_path, :save_prjconf, :clear_failed_comment, :pulse]

# TODO: check if get_by_name or set_by_name is used for save_prjconf
before_action :set_project_by_name, only: [:save_meta, :save_prjconf]
Expand Down Expand Up @@ -92,6 +92,10 @@ def subprojects
@siblings = @project.siblingprojects
end

def pulse
@pulse = @project.project_log_entries.page(params[:page])
end

def new
@project = Project.new
@project.name = params[:name] if params[:name]
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/helpers/webui/webui_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def description_wrapper(description)
end

def is_advanced_tab?
action_name.in?(['prjconf', 'index', 'meta', 'status'])
action_name.in?(['prjconf', 'index', 'meta', 'status', 'pulse'])
end

def sprite_tag(icon, opts = {})
Expand Down
2 changes: 2 additions & 0 deletions src/api/app/models/project_log_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def additional_info
def self.username_from(payload)
USERNAME_KEYS.each do |key|
username = payload[key]
# FIXME: Why is commenter `id`` when everything else is `login`?
username = User.find_by(id: payload[key]).try(:login) if key == 'commenter'
return username unless username.blank? || username == 'unknown'
end
return
Expand Down
1 change: 1 addition & 0 deletions src/api/app/views/webui/project/_tabs.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<%= tab 'attribute', 'Attributes', :controller => :attribute, :project => @project, :action => 'index' %>
<%= tab 'meta', "Meta", :controller => :project, :action => :meta %>
<%= tab 'status', 'Status', :controller => :project, :action => :status unless @project.defines_remote_instance? || @is_maintenance_project %>
<%= tab 'pulse', 'Pulse', :controller => :project, :action => :pulse %>
<% end -%>
</ul>
</div>
Expand Down
19 changes: 19 additions & 0 deletions src/api/app/views/webui/project/pulse.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- @pagetitle = "Pulse of #{@project}"
- project_bread_crumb 'Pulse'


= render partial: 'webui/project/tabs'
%h3 Pulse of #{@project}
- @pulse.each do |log_entry|
%p
&bull;
= log_entry.event_type.camelcase.prepend('Event::').constantize.description
- if log_entry.package_name
(#{link_to(log_entry.package_name, package_show_path(@project.name, log_entry.package_name))})
- if log_entry.user_name
by #{link_to(log_entry.user_name, user_show_path(log_entry.user_name))}
- if log_entry.bs_request
via request #{link_to("##{log_entry.bs_request.number}", request_show_path(log_entry.bs_request.number))}
= fuzzy_time(log_entry.datetime)

= paginate @pulse
1 change: 1 addition & 0 deletions src/api/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ def self.public_or_about_path?(request)
post 'project/remove_maintained_project/:project' => :remove_maintained_project, constraints: cons
get 'project/maintenance_incidents/:project' => :maintenance_incidents, constraints: cons
get 'project/list_incidents/:project' => :list_incidents, constraints: cons
get 'project/pulse/:project' => :pulse, constraints: cons
get 'project/unlock_dialog' => :unlock_dialog
post 'project/unlock' => :unlock
end
Expand Down
4 changes: 2 additions & 2 deletions src/api/db/data/20180214132015_project_log_entry_user_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class ProjectLogEntryUserName < ActiveRecord::Migration[5.1]
def up
ProjectLogEntry.where('event_type like "%comment_for%"').in_batches do |log_entry|
user = User.find_by(id: log_entry.user_name).try(:login)
user ||= '_nobody_'
user ||= User::NOBODY_LOGIN
# rubocop:disable Rails/SkipsModelValidations
log_entry.update_attribute(user_name: user)
# rubocop:enable Rails/SkipsModelValidations
Expand All @@ -12,7 +12,7 @@ def up
def down
ProjectLogEntry.where('event_type like "%comment_for%"').in_batches do |log_entry|
user = User.find_by(id: log_entry.user_name).try(:id)
user ||= User.find_nobody!.try(:id)
user ||= User.find_nobody!.try(:id)
# rubocop:disable Rails/SkipsModelValidations
log_entry.update_attribute(user_name: user)
# rubocop:enable Rails/SkipsModelValidations
Expand Down

0 comments on commit 328067f

Please sign in to comment.