Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2915 from bgeuken/maintenance_stats_
Maintenance stats for remote projects
- Loading branch information
Showing
3 changed files
with
39 additions
and
6 deletions.
There are no files selected for viewing
21 changes: 17 additions & 4 deletions
21
src/api/app/controllers/statistics/maintenance_statistics_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 |
---|---|---|
@@ -1,12 +1,25 @@ | ||
module Statistics | ||
class MaintenanceStatisticsController < ApplicationController | ||
skip_before_action :extract_user | ||
skip_before_action :extract_user, :require_login | ||
|
||
def index | ||
@project = Project.get_by_name(params[:project]) | ||
@maintenance_statistics = MaintenanceStatisticDecorator.wrap( | ||
MaintenanceStatistic.find_by_project(@project) | ||
) | ||
if @project.is_a?(String) | ||
# FIXME: This could be simplified by redirecting to the remote instead | ||
remote_instance, remote_project = Project.find_remote_project(@project) | ||
remote_response = ActiveXML.backend.load_external_url( | ||
"#{remote_instance.remoteurl}#{maintenance_statistics_path(project: remote_project)}" | ||
) | ||
if remote_response | ||
render xml: remote_response | ||
else | ||
render_error status: 404, errorcode: 'remote_project', message: "Project '#{@project}' not found" | ||
end | ||
else | ||
@maintenance_statistics = MaintenanceStatisticDecorator.wrap( | ||
MaintenanceStatistic.find_by_project(@project) | ||
) | ||
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
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