Add count keys to response JSON

This commit is contained in:
Z.J. van de Weg 2017-02-15 19:59:30 +01:00
parent b8dbebce1d
commit a254dcf0ed
1 changed files with 4 additions and 3 deletions

View File

@ -29,9 +29,8 @@ class Projects::EnvironmentsController < Projects::ApplicationController
end
def folder
@environments = project.environments
.where(environment_type: params[:id])
.with_state(params[:scope] || :available)
folder_environments = project.environments.where(environment_type: params[:id])
@environments = folder_environments.with_state(params[:scope] || :available)
respond_to do |format|
format.html
@ -41,6 +40,8 @@ class Projects::EnvironmentsController < Projects::ApplicationController
.new(project: @project, user: @current_user)
.with_pagination(request, response)
.represent(@environments),
available_count: folder_environments.available.count,
stopped_count: folder_environments.stopped.count
}
end
end