-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move pulse related code to it's own controller
I tried to use Rails resourceful routing, but that woulde create different routes than we had before: 'project/:project/pulse' instead of 'project/pulse/:project'.
- Loading branch information
1 parent
3c15e4b
commit 0e3b6cd
Showing
21 changed files
with
144 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/api/app/controllers/webui/projects/pulse_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module Webui | ||
module Projects | ||
class PulseController < WebuiController | ||
before_action :set_project | ||
|
||
def show | ||
switch_to_webui2 | ||
@pulse = @project.project_log_entries.page(params[:page]) | ||
end | ||
|
||
def update_pulse | ||
@range = params[:range] == 'month' ? 'month' : 'week' | ||
case @range | ||
when 'month' | ||
range = 1.month.ago..Date.tomorrow | ||
else | ||
range = 1.week.ago..Date.tomorrow | ||
end | ||
|
||
pulse = @project.project_log_entries.where(datetime: range).order(datetime: :asc) | ||
@builds = pulse.where(event_type: [:build_fail, :build_success]) | ||
@new_packages = pulse.where(event_type: :create_package) | ||
@deleted_packages = pulse.where(event_type: :delete_package) | ||
@branches = pulse.where(event_type: :branch_command) | ||
@commits = pulse.where(event_type: :commit) | ||
@updates = pulse.where(event_type: :version_change) | ||
@comments = pulse.where(event_type: [:comment_for_package, :comment_for_project]) | ||
@project_changes = pulse.where(event_type: [:update_project, :update_project_config]) | ||
|
||
@requests = @project.target_of_bs_requests.where(updated_at: range).order(updated_at: :desc) | ||
# group by state, sort by value... | ||
@requests_by_state = @requests.group(:state).count.sort_by { |_, v| -v }.to_h | ||
# transpose to percentages | ||
@requests_by_percentage = @requests_by_state.each_with_object({}) { |(k, v), hash| hash[k] = (v * 100.0 / @requests_by_state.values.sum).round.to_s } if @requests_by_state.any? | ||
switch_to_webui2 | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
7 changes: 0 additions & 7 deletions
7
src/api/app/views/webui2/webui/project/_pulse_list_branches.html.haml
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
src/api/app/views/webui2/webui/project/_pulse_list_builds.html.haml
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
src/api/app/views/webui2/webui/project/_pulse_list_commits.html.haml
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
src/api/app/views/webui2/webui/projects/pulse/_breadcrumb_items.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../project/_breadcrumb_items.html.haml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/api/app/views/webui2/webui/projects/pulse/_pulse_list_branches.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
- if @branches.any? | ||
People | ||
= link_to('#pulse-collaboration') do | ||
branched | ||
#{pluralize(@branches.count, 'package')}. | ||
- else | ||
No one branched packages from this project. |
21 changes: 21 additions & 0 deletions
21
src/api/app/views/webui2/webui/projects/pulse/_pulse_list_builds.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
- if @builds.any? | ||
- builds = @builds.group(:event_type).count | ||
There | ||
-# 'has' does not have an inflection and the String | ||
version of pluralize does not know about the plural | ||
option like, that's why this is an if... | ||
'has'.pluralize(builds.values.sum, plural: 'have') | ||
= builds.values.sum > 1 ? 'have' : 'has' | ||
been | ||
= link_to('#pulse-builds') do | ||
= builds.values.sum | ||
builds | ||
of which | ||
%b.text-danger | ||
= builds['build_fail'] | ||
failed | ||
and | ||
%b.text-success | ||
= builds['build_success'] | ||
succeeded | ||
\. |
File renamed without changes.
6 changes: 3 additions & 3 deletions
6
...ui/project/_pulse_list_comments.html.haml → ...ects/pulse/_pulse_list_comments.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/api/app/views/webui2/webui/projects/pulse/_pulse_list_commits.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
- if @commits.any? | ||
- people = @commits.group(:user_name).count | ||
%b | ||
= pluralize(people.count, 'person') | ||
added | ||
= link_to('#pulse-packages') do | ||
= pluralize(@commits.count, 'commit') | ||
to packages in this project. | ||
- if @updates.any? | ||
Out of those commits, | ||
= pluralize(updates.count, 'was a', plural: 'were') | ||
version #{'update'.pluralize(updates.count)}. | ||
- top_committer = commits.group(:user_name).count.max_by { |_, v| v } | ||
%span{ title: "with #{pluralize(top_committer.second, 'commit')}" } | ||
= top_committer.first | ||
was the busiest commiter, hooray! | ||
- else | ||
no one committed anything. |
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions
18
src/api/app/views/webui2/webui/projects/pulse/_pulse_list_requests.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.row | ||
- @requests.take(30).each do |request| | ||
%dt.col-1 | ||
%span{ class: "badge progress-state-#{request.state} text-light" } | ||
= request.state.to_s | ||
%dd.col-11 | ||
= link_to(request_show_path(request.number)) do | ||
= request.number | ||
(#{truncate(request.description)}) | ||
- if request.request_history_elements.any? | ||
= request.request_history_elements.last.description.gsub('Request', '') | ||
- else | ||
was created | ||
by | ||
= link_to(user_show_path(request.creator)) do | ||
= request.creator | ||
= fuzzy_time(request.updated_at) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../project/_tabs.html.haml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../webui2/webui/project/update_pulse.js.erb → .../webui/projects/pulse/update_pulse.js.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
$('#range-header').html("<%= escape_javascript(pulse_period(@range)) %>"); | ||
$('#range-text').html("<%= @range.titleize %>"); | ||
$('#pulse').html("<%= escape_javascript render partial: 'pulse_list' %>"); | ||
$('#pulse').html("<%= escape_javascript render partial: 'pulse_list' %>"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters