summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorPawel Chojnacki <pawel@chojnacki.ws>2017-03-28 14:56:30 +0200
committerPawel Chojnacki <pawel@chojnacki.ws>2017-03-28 14:56:30 +0200
commitd3e794e26f806fe491269a74e76c39669433c0fe (patch)
treee094ecabf28df0007325a524980a0c0b22a840cb /app/controllers
parent73203873438d666427228ffdbfe835ea4ffddaa6 (diff)
downloadgitlab-ce-d3e794e26f806fe491269a74e76c39669433c0fe.tar.gz
Optionally filter by deployment time
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/projects/deployments_controller.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/app/controllers/projects/deployments_controller.rb b/app/controllers/projects/deployments_controller.rb
index ed0f802dbd9..a8a6f09d9df 100644
--- a/app/controllers/projects/deployments_controller.rb
+++ b/app/controllers/projects/deployments_controller.rb
@@ -2,9 +2,11 @@ class Projects::DeploymentsController < Projects::ApplicationController
before_action :authorize_read_deployment!
def index
- serializer = DeploymentSerializer.new(user: @current_user)
- deployments = environment.deployments.where('created_at > ?', 8.hours.ago)
- .map { |d| serializer.represent(d) }
+ serializer = DeploymentSerializer.new(user: @current_user, project: project)
+
+ deployments = environment.deployments.reorder(created_at: :desc)
+ deployments = deployments.where('created_at > ?', params[:after].to_time) if params[:after]&.to_time
+ deployments = deployments.map { |deployment| serializer.represent(deployment) }
render json: { deployments: deployments }
end